Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When I enter the command

Start-Process powershell -WorkingDirectory "D:folder"

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

But when I enter the command

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

it opens new PowerShell window with admin rights but with C:Windowssystem32 location set.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...