gpt4 book ai didi

windows - 使用 PowerShell 提升当前目录中的权限

转载 作者:行者123 更新时间:2023-12-02 22:38:30 25 4
gpt4 key购买 nike

例如,我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com