Hi guys,
I want to execute one command using batch file but non of below code is working where Please tell me where I am going wrong,
Following is code for executing batch file,
First trial:-
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess( NULL,
"cmd /C sa.bat",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi )
)
{
printf( "CreateProcess failed (%d)\n", GetLastError() );
return FALSE;
}
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return TRUE;
Second trial :-
system("cmd.exe /C sa.bat");
Third Trial :-
_execlpe("cmd", "/c", "sa.bat", static_cast<char*>(0));
Fourth Trial :-
WinExec("sa.bat",SW_SHOWNORMAL);
Fifth Trial :-
ShellExecute(GetDesktopWindow(), "sa.bat","", NULL, NULL, SW_SHOWNORMAL);
Non of above code is working for me but when open same batch file using double click it work like I expected.
Following is content of the file,
C:\\windows\\system32\\wusa /uninstall /kb:2718695 /quiet /forcerestart
Command use to uninstall internet explorer 10 an install internet explorer9.
Any help ,link ,block of code are most welcome.