There used to be a shutdown dialog box that describes how to invoke the system using the command line:
Specific method: Start/Run:
Copy Code code as follows:
rundll32.exe Shell32.dll #60
However, the above method will have a problem, XP can not normally use this method for shutdown (thanks to netizens mu ye found the problem). The problem may be that, under normal circumstances, the Shutdown dialog box has a Explorer.exe call, and the command cannot be triggered directly using the Rundll32 call.
Now that we can use the Explorer.exe call, we can try to implement it using a script. Implementation principle:
Activate Explorer.exe
Press Alt+f4
Write the VBS script as follows (save the following as Shutdown.vbs):
Copy Code code as follows:
Dim objwmi,wsh
Dim colprocesses,objprocess
Pid=0
Set objwmi = GetObject ("winmgmts:{impersonationlevel=impersonate}//. /root/cimv2 ")
Set colprocesses = Objwmi.execquery ("SELECT * from Win32_Process" & _
"WHERE name= ' explorer.exe '")
For each objprocess in colprocesses
PID = Objprocess.processid
Next
Set wsh = WScript.CreateObject ("Wscript.Shell")
Wsh. AppActivate PID
Wsh.sendkeys "%{f4}"
The script running environment is: XP SP2
Other environments may also work correctly, but for systems with multiple Explorer.exe processes, it may not work properly, as in a multiuser environment with remote Terminal Services.