正如标题所说,shutdown /s /t xx
当我从脚本运行典型命令时,它不起作用。它不会在几秒钟后关闭x
,而是只运行该shutdown
部分,并忽略参数。但是,如果我在命令提示符窗口中手动键入它,它会正确执行。我尝试从类似的脚本运行其他命令,ipconfig /all
但没有问题。这是一般的 Windows 10 问题还是我的计算机上出现了问题?
PS 我也得到了与 Powershell 相同的结果。
正如标题所说,shutdown /s /t xx
当我从脚本运行典型命令时,它不起作用。它不会在几秒钟后关闭x
,而是只运行该shutdown
部分,并忽略参数。但是,如果我在命令提示符窗口中手动键入它,它会正确执行。我尝试从类似的脚本运行其他命令,ipconfig /all
但没有问题。这是一般的 Windows 10 问题还是我的计算机上出现了问题?
PS 我也得到了与 Powershell 相同的结果。
将此作为诊断步骤进行测试。
@echo off
"c:\Windows\System32\shutdown.exe" /s /t 20
pause
换掉我们的/s /t xx
for -s -t xx
。这在我的 Windows 10 系统上解决了这个问题。
Might be worth mentioning Powershell doesn't always play nice with external executables and command line switches/arguments. Try using:
Start-Process shutdown.exe -ArgumentList "/s /t 20"
Also, there is Invoke-Item
which can start a process but I've noticed using Start-Process
Reference this for more information.
在 PowerShell 中,您可以使用Stop-Computer
.