winapi - windows API shellexecute is failing to execute batch file -


i trying execute batch file using shellexecute, not getting executed. below way using api:

temp += "cmd.exe /c c:\\autotest\\target1_cmdlist.bat ";     hinstance hreturncode=shellexecute(null, _t("open"), null,temp.c_str(), "c:\\autotest", sw_hide); 

can tell me right way? searched posts mentioned same , made changes accordingly.

thanks

you passing null lpfile argument. argument cannot omitted , must specify name of file wish perform action on.

presumably meant write:

shellexecute(null, _t("open"), temp.c_str(), null, "c:\\autotest", sw_hide); 

there little point in passing cmd.exe shellexecute. shell knows .bat file. pass .bat file directly.

it better use shellexecuteex since capable of proper error reporting, unlike shellexecute. check errors described @ msdn. check return value of shellexecuteex, , if false call getlasterror obtain error code.

what more, seems incongruous use _t() macro times , not others. suggest stop using _t() macro , decide whether target ansi or unicode.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -