• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

运行命令以管理员身份与规格

windows 来源:scriptmastere02 6次浏览

条件,我想以管理员身份运行命令以管理员身份与规格

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 -Command "Start-Process -FilePath C:\Windows\System32\sleep.exe -ArgumentList -m,500" 

版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)