Reputation: 65
For example I'm in C:\Users\User\Desktop\Tools
and I'm trying to stay here as admin.
I tried this way, gluing together different commands:
"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit" & -windowstyle hidden -Command Start-Process powershell -ArgumentList '-NoExit', '-Command cd %V' -Verb runAs""
The PATH changes to C:\WINDOWS\system32
why? How to elevate rights in current directory via simple command?
Upvotes: 3
Views: 192
Reputation: 174445
Use $PWD
from the calling process to change the location on startup:
Start-Process powershell -ArgumentList '-NoExit', "-Command cd '$pwd'; & .\actual\script\you\want\to\run.ps1" -Verb runAs
Upvotes: 3