例如,我在 C:\Users\User\Desktop\Tools
中,我想以管理员身份留在这里。
我尝试过这种方式,将不同的命令粘合在一起:
"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit" & -windowstyle hidden -Command Start-Process powershell -ArgumentList '-NoExit', '-Command cd %V' -Verb runAs""
PATH 更改为 C:\WINDOWS\system32
为什么?如何通过简单命令提升当前目录的权限?
最佳答案
在调用进程中使用 $PWD
来更改启动时的位置:
Start-Process powershell -ArgumentList '-NoExit', "-Command cd '$pwd'; & .\actual\script\you\want\to\run.ps1" -Verb runAs
关于windows - 使用 PowerShell 提升当前目录中的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63860359/