條件,我想以管理員身份運行命令以管理員身份與規格
sleep -m 500
所以我用這個命令來運行這個命令cmd
。
powershell -Command "Start-Process sleep.exe -m 500 -Verb runas"
錯誤出現了:
Start-Process : A parameter cannot be found that matches parameter name 'm'. At line:1 char:47 + Start-Process C:\Windows\System32\sleep.exe -m <<<< 500 -Verb runas + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
然後,我用這個命令
powershell -Command "Start-Process 'sleep.exe -m 500' -Verb runas"
錯誤出現了:
Start-Process : This command cannot be executed due to the error: The system cannot find the file specified. At line:1 char:14 + Start-Process <<<< 'C:\Windows\System32\sleep.exe -m 500' -Verb runas + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
然後,我用這樣的:
powershell -Command "Start-Process sleep.exe /m 500 -Verb runas"
錯誤出現了:
Start-Process : A positional parameter cannot be found that accepts argument '500'. At line:1 char:14 + Start-Process <<<< C:\Windows\System32\sleep.exe /m 500 -Verb runas + CategoryInfo : InvalidArgument: (:) [Start-Process], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand
誰能告訴我正確的命令呢?我希望它是批處理版本。
'PowerShell幫助啓動process' – ACatInLove
PowerShell和批次是完全不同的語言 – SomethingDark
是的,我知道,我只是無法弄清楚如何運行'睡眠 - m 500'作爲管理員使用powershell ..是啊,我知道如何使用'-verb runas'作爲管理員運行它,但我怎樣才能執行我想運行的命令('sleep -m 500')? – scriptmastere02