Roe*_*ati 4 powershell cmd administrator
我正在尝试使用 powershell 以管理员身份执行命令提示符。(就像当您按右键单击 cmd 图标并选择以管理员身份运行时)。为了做到这一点,我应该在以下内容中添加什么?
& cmd.exe /c $VAR
Run Code Online (Sandbox Code Playgroud)
有点模糊,您必须使用Start-Processwith 参数-Verb RunAs才能在 PowerShell 中启动提升的进程(具有管理权限的进程):
# The command to pass to cmd.exe /c
$var = 'echo hello world & pause'
# Start the process asynchronously, in a new window,
# as the current user with elevation (administrative rights).
# Note the need to pass the arguments to cmd.exe as an *array*.
Start-Process -Verb RunAs cmd.exe -Args '/c', $var
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17962 次 |
| 最近记录: |