Start-Process -WorkingDirectory 作为管理员未设置位置 [英] Start-Process -WorkingDirectory as administrator does not set location

查看:38
本文介绍了Start-Process -WorkingDirectory 作为管理员未设置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入命令时

Start-Process powershell -WorkingDirectory "D:\folder"

它打开带有 D:\folder 位置集的新 PowerShell 窗口.

it opens new PowerShell window with D:\folder location set.

但是当我输入命令时

Start-Process powershell -WorkingDirectory "D:\folder" -Verb RunAs

它打开具有管理员权限的新 PowerShell 窗口带有 C:\Windows\system32 位置集.

it opens new PowerShell window with admin rights but with C:\Windows\system32 location set.

如何使用管理员权限和确定我自己的位置打开新的 PowerShell 窗口?

How can I open new PowerShell window with admin rights and my own location determined?

推荐答案

我也遇到了同样的问题,用这个命令解决了:

I also had the same problem and solved it with this command:

Start-Process powershell.exe -verb runAs -ArgumentList '-NoExit', '-Command', 'cd D:\folder'

运行上述命令后,Windows 将使用管理员权限和指定目录启动.

Once you run the above command, Windows will launch with admin authority and the specified directory.

这篇关于Start-Process -WorkingDirectory 作为管理员未设置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆