PHP实现关闭远程计算机
有很多方法可以实现远程计算机,这里讲下如果关闭远程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);?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.
