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

标签 windows powershell

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

相关文章:

windows - 在数组中查找变量 - 批处理

windows - 颜色问题

windows - 使用 Windows Control-C 剪贴板复制时如何保留制表符 `n` n?

azure - 运行带参数的 Set-AzVMRunCommand 命令会在目标上生成奇怪的失败文件

powershell - SCCM-使用PowerShell更改现有部署截止日期

powershell - 通过 Powershell 运行时 MSBuild 失败

Android Studio 2.1 无法安装在 Windows 10 专业版 64 位系统(内部版本 10240)中?

c++ - 程序没有使用所有 CPU?

c - 如何从错误偏移中确定调用的 kernel32.dll 函数

powershell - Powershell-输出目录递归到控制台和文件