I use this code C++ builder to execute batch file in remote computer
String PsExec = ExtractFilePath(Application->ExeName) + "PSTools\\PsExec.exe";
String lcParam = " \\"+gl_HostName+" cmd /c "+TDirectory::GetParent(rootPath)+"\\...\\File1.bat "+IntToStr(8988) ;
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = PsExec.c_str();
ShExecInfo.lpParameters = lcParam.c_str();
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_NORMAL;//SW_HIDE ;
ShExecInfo.hInstApp = NULL;
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
bool res = ShellExecuteEx(&ShExecInfo); // Call to function
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
It doesn't work!
But, when I run a cmd into console :
\PSTools> PsExec.exe \\x.y.z.w \\x.y.z.w\.....\File1.bat 8988
It works correctly and runs this batch in a remote computer!
What is wrong in my sample code?