使用 Windows 7 中的批处理文件从另一台 PC 关闭 LAN 上的 PC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11308410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:39:41  来源:igfitidea点击:

Shutdown a PC on LAN from another PC using a batch file in Windows 7

windowsbatch-fileshutdownlan

提问by Amith

I'm just interested in knowing: can we shutdown a PC from another PC using a batch file if both are on the same LAN?

我只是想知道:如果两台电脑都在同一个局域网上,我们可以使用批处理文件从另一台电脑上关闭一台电脑吗?

回答by Bali C

Yes, you can use the /mswitch for shutdownlike this

是的,您可以像这样使用/m开关shutdown

shutdown /s /m \computer1 /t 0

回答by Alex K.

Call the shutdowncommand from a batch running as a user with the correct permissions or use psshutdown.

从以具有正确权限的用户身份运行的批处理中调用关闭命令或使用psshutdown

回答by rebane2001

Easiest way:

最简单的方法:

set computertoshutdown=COMPUTERNAME
set timetoshutdown =TIMEtoSHUTDOWN
set message=MESSAGE

shutdown -s -m \%computertoshutdown% -t %timetoshutdown% -c "%message%"

回答by armyguy556

This should work but you can shutdown any computer in your wifi range to find the name of the computer press the Win+Pause+Breakkeys all at the same time then go to computer name.

这应该可以工作,但您可以关闭wifi范围内的任何计算机以查找计算机名称同时按Win+ Pause+Break键然后转到计算机名称。

@Echo off
 cd\
 Echo Saman=Program
 REM ****************************
 REM * Program Variables *
 REM ****************************

 set varcomputer=[computername]
 goto loop
 :[computername]

 Exit

 REM ****************************
 REM * Program *
 REM ****************************

 :loop
 echo Shutting down %varcomputer%.
 shutdown -s -m \%varcomputer% -t 600 -c "The computer is shutting down. Please save your work."
 goto %varcomputer