Createprocess to restart system on 64 bit 2003 r2 server.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a vc++ win32 application which has a generic method to invoke command line arguments running on Windows 2003 r2 64 bit.
<p style="margin-bottom:.0001pt; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:"Courier New"; color:blue
<pre>void ExucuteProcess(LPSTR exeCmd)
{
STARTUPINFO startInfo;
PROCESS_INFORMATION processInfo;
memset(&startInfo, 0, sizeof(startInfo));
startInfo.cb=sizeof(startInfo);
memset(&processInfo, 0, sizeof(processInfo));
::CreateProcess(NULL, exeCmd, NULL, NULL, FALSE,CREATE_NO_WINDOW,NULL,NULL,&startInfo, &processInfo);
WaitForSingleObject(processInfo.hProcess,INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}

[/code]
<br/>
<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New" I have another method which call the ExcuteProcess to restart the system
<span style="font-family:Courier New; font-size:xx-small <span style="line-height:14px <br/>

<pre>ExecuteProcess("shutdown /r /t 0 /f /d P:2:17 /c "Installed xyz application"")[/code]

<span style="font-family:Courier New; font-size:x-small <span style="line-height:14px <br/>
But the above method gives and error 2 âSystem cannot find the path specified.â
This executes fine on Windows 2003 server 32 bit but not on 2003 r2 64 bit.
I have also tried specifying the complete path <span style="font-size:10.0pt; line-height:115%; font-family:"Courier New"

<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New"
<pre>ExecuteProcess("C:\windows\system32\shutdown /r /t 0 /f /d P:2:17 /c "Installed applications"")

[/code]
<br/>
<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New" Still I get the same error.
<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New" Is this a know issue? Is there any other method to restart system from code?
<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New"
<span style="font-size:10.0pt; line-height:115%; font-family:"Courier New" Thanks.
<br/>
<br/>
<br/>

View the full article
 
Back
Top