Computer restart script

Source: Internet
Author: User

Solution 1:
Set oshell = wscript. Createobject ("wscript. Shell ")
Oshell. Run "shutdown-r-F-T 1", true
Problems:
Shutdown is an XP command, so this script cannot be run in Win2k.
Even in XP, it is only applicable to Super Users. After a common user executes the command in DOS, the following message is displayed:
The operation is successful.
The client does not have the required privileges.
(If you copy shutdown to Win2k, this prompt is also displayed for normal users)
Therefore, this script cannot be restarted under normal users. The practicality is as follows: 2.

Strictly speaking, to use shutdown, a common user must have two permissions: seshutdownprivilege and SeRemoteShutdownPrivilege ). You can use tokenmon to verify this and solve the problem by adding the remote shutdown permission to the interactive group. For more details, see log 03640. In addition, the commonly used procexp.exe (process Explorer) can also seeProgramPermissions.

Solution 2:
If shutdown is faulty, try another shutdown command, such as rundll32 shell32 and shexitwindowsex 2.
However, in Win2k and XP, the results are as follows:
Shell32 Error
Lost entry: shexitwindowsex

Another command for Win98 is also moved: rundll32 user.exe, restartwindows
Tips for running XP:
The application or DLL c: \ windows \ system32 \ user.exe is an invalid Windows Image. Check your installation disk again.
An error occurred while loading user.exe.
% 1 is not a valid Win32 application.
Running in Win2k, these prompts are not displayed, but there is no effect.

To change to user32.exe, both XP and Win2k are prompted:
Error loading user32.exe
The specified module cannot be found.

Windows XP: rundll32 shell32, #59
Tip: @ # $ % the computer must be restarted to make the new settings take effect.
Do you want to restart the computer now?
But click "yes", but it does not restart. The system also prompts that we need to change the information.

Practicality: 0

Solution 3:
Show shutdown dialog box
Set oapplication = Createobject ("shell. application.1 ")
Oapplication. shutdownwindows ()
Although it can run well in Win2k and XP, it only displays the shutdown dialog box. The user chooses to shut down, restart, or log off, click OK. On the network, you can use the send cursor to move up and down keys and press enter to enable automatic restart. I feel that it is not a good solution.

Practicality: 1

Solution 4:
Restart with Batch Processing
@ Echo off
Setlocal
CD/d % Temp %
Echo [version]> Reboot. inf
Set INF = installhinfsection defaultinstall
Echo Signature = $ Chicago $> Reboot. inf
Echo [defainstall install]> Reboot. inf
Rundll32 setupapi, % INF % 1% TEMP % \ reboot. inf
Del reboot. inf
AboveCodeThere are many learning areas, including setlocal, CD/d, and rundll32 setupapi. However, in Win2k and XP, normal accounts run the following results: Installation failed. So no restart is successful. Superusers are normal. It is estimated that the Registry HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ runonce must have full control permissions.

Practicality: 1

Solution 5:
WMI
The Code is as follows:
Set owmi = GetObject ("winmgmts :"&_
"{Impersonationlevel = impersonate, (shutdown )}! "&_
"\\."&_
"\ Root \ cimv2 ")
Set Coss = owmi. execquery ("select * From win32_operatingsystem ")
For each OOS in Coss
Oos. Reboot ()
Next

It is applicable to both Win2k and XP.
Finally, use it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.