Previously there was a dialog box showing how to call a system shutdown using command lines: http://blog.csdn.net/scz123/archive/2005/09/30/492991.aspx
Method: Start/run: rundll32.exe shell32.dll #60
However, the above method will have a problem, XP cannot use this method to shut down (thanks to the netizen Mu ye for discovering this problem ). The cause may be: Normally, the host dialog box is called by assumer.exe. commands cannot be triggered when rundll32 is directly used.
Even though you can use assumer.exe to call it, we can try to use a script to implement it. Implementation principle:
- Activate assumer.exe
- Press Alt + F4
Write the following vbs script (Save the following content as shutdown. vbs): dim ob1_mi, wsh
Dim colprocesses, objprocess
PID = 0
Set ob1_mi = GetObject ("winmgmts: {impersonationlevel = impersonate} //./root/cimv2 ")
Set colprocesses = ob1_mi. execquery ("select * From win32_process "&_
"Where namepolic'assumer.exe '")
For each objprocess in colprocesses
PID = objprocess. processid
Next
Set wsh = wscript. Createobject ("wscript. Shell ")
Wsh. appactivate PID
Wsh. sendkeys "% {F4 }"
The above script runtime environment is XP SP2
Other environments can also work normally. However, systems with multiple cmd.exe processes may not work normally, such as multi-user environments with remote terminal services.