PHP Implementation shutdown remote computer

Source: Internet
Author: User
Tags requires

There are a number of ways to implement a remote computer, and here's a word. If you shut down a remote Windows computer, first extract a shutdown command description

The shutdown command syntax is: shutdown [-i |-l|-s |-r |-a] [-f] [-M [\\ComputerName]] [-t XX] [-C "message"] [-d[p]:xx:yy].

The "-I" dialog box displays a graphical interface.

'-l ' Log off the current user as the default setting.

'-S ' shuts down the computer.

Reboot after the "-R" shutdown.

'-a ' aborts shutdown.

"-F" forces the application to be closed.

"-M [\\ComputerName] Specifies the computer to be shut down.

"-T XX" sets the timer used for system shutdown to xx seconds, and the default value is 20 seconds.

The "-C" message "specifies the messages that will be displayed in the messages area in the System Shutdown window, which can be up to 127 characters long and must contain a message in quotation marks.

"-D [p]:xx:yy" lists reason codes for system shutdown.

Except for "-L" and "ComputerName", the system ignores other parameters. Only "-a" can be used during the timeout period.

For example, turn off the remote computer and enter "Shutdown-s-m \\WORK1-T 60", which means that the machine named work will be shut down after 60 seconds, and the machine must also have the Windows XP operating system installed. The input "shutdown-s-T 30" means that the machine shuts down automatically after 30 seconds. "Shutdown-l" means logging off the native user, which does not apply to the remote computer. Use "Shutdown-r" to reboot the local computer. "Shutdown-a" can cancel a shutdown command that has been released. You can use "Shutdown-s" when you want to shut down the local computer.

In PHP, System and exec can perform shutdown commands if the remote computer's hardware and software configuration meets the following criteria: Granting the Guest user permission to remote shutdown. When a remote user connects to a local Windows XP system as a guest, the remote shutdown requires administrator privileges, so the guest user is given permission to remote shutdown. Start the computer that requires a remote shutdown, enter "Gpedit.msc" in the Run dialog box, and open Group Policy Editor. Expand Computer Configuration → "Windows settings" → "Security Settings" → "Local Policy" → "User Rights Assignment", and in the right window, locate the "Force shutdown from remote system" option. Double-click the item, in the pop-up dialog box, select the Add button, enter the username "Guest" in the new dialog box, and then click OK. The "Guest" user is now in the "Force shutdown from remote system" attribute, and click OK to exit.

Code:

<?php

system('shutdown -s -m \\work1 -t 60');

?>

Related Article

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.