我正在尝试制作一个bacth文件,该文件将制作第二个bacth,并将其内容设置为:
powershell关闭/s/f/t 0
我尝试使用的命令是powershell设置内容"shutdown.bat"powershell shutdown/s/f/t 0">
当我运行它时,我会得到这个:
Set-Content : A positional parameter cannot be found that accepts argument 'shutdown'.
At line:1 char:1
+ set-content -Path shutdown.bat -Value powershell shutdown /s /f /t 0
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Content], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand
这个。。。
powershell shutdown /s /f /t 0
不是使用Powershell运行外部命令行工具或其他程序的方法。要运行外部工具,这是一件有据可查的事情。。。
PowerShell:运行可执行文件
解决PowerShell 中的外部命令行问题
Powershell 中运行外部命令的五大技巧
使用Windows PowerShell运行旧的命令行工具(及其最奇怪的参数(
PowerShell中外部命令的执行正确
。。。以及相当日常的活动。
当你做你想要做的事情时,正确的引用和论点终止是一项要求。
所以,像这样的东西。。。
powershell -ArgumentList '-Command &{ shutdown /s /f /t 0 }'