search
Homephp教程php手册PHP实现关闭远程计算机

PHP实现关闭远程计算机

Jun 13, 2016 am 10:38 AM
phpwindowsclosureCanaccomplishmethodhavecomputerRemotely

        有很多方法可以实现远程计算机,这里讲下如果关闭远程WINDOWS计算机,先摘录一段shutdown命令说明

Shutdown命令语法格式为:shutdown [-i |-l|-s |-r |-a] [-f] [-m [\ComputerName]] [-t xx] [-c "message"] [-d[p]:xx:yy]。

“-i”显示图形界面的对话框。

“-l”注销当前用户,为默认设置。

“-s”关闭计算机。

“-r”关闭之后重新启动。

“-a”中止关闭。

“-f”强制运行要关闭的应用程序。

“-m [\ComputerName] 指定要关闭的计算机。

“-t xx”将用于系统关闭的定时器设置为 xx 秒,默认值是 20 秒。

“-c "message"”指定将在“系统关闭”窗口中的“消息”区域显示的消息,最多可以使用 127 个字符,引号中必须包含消息。

“-d [p]:xx:yy”列出系统关闭的原因代码。

除了“-l”和“ComputerName”外,系统将忽略 其他参数。在超时期间,只可以使用“-a”。

例如,关闭远程计算机输入“shutdown -s -m \work1 -t 60 ”,表示在60秒后关闭计算机名为work的机器,该机必须同样装有Windows XP操作系统。而输入“shutdown - s -t 30”则表示在30秒后自动关机。“shutdown -l”表示注销本机用户,这对远程计算机不适用。使用“shutdown -r”则重启本地计算机。“Shutdown -a”就可以取消已经下达的关机命令。而要关闭本地计算机时,可以使用“shutdown -s”。

PHP中system和exec可以执行关机命令,如果远程计算机的软硬件配置符合如下条件可以执行:赋予Guest用户远程关机的权限。远程用户 连接到本地Windows XP系统中时是以Guest身份连接的,而远程关机需要管理员权限,因此要先赋予Guest用户远程关机的权限。启动需要远程关机的电脑,在“运行”对话 框中输入“gpedit.msc”,打开“组策略编辑器”。依次展开“计算机配置”→“Windows 设置”→“安全设置”→“本地策略”→“用户权利指派”,在右侧窗口中找到“从远端系统强制关机”选项。双击该项目,在弹出对话框中单击“添加”按钮,然 后在新对话框中输入用户名“guest”,最后点击“确定”。现在“从远端系统强制关机”的属性中就多出了“guest”用户,单击“确定”按钮退出。


代码:

        system(shutdown -s -m \work1 -t 60);
    ?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool