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

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.
