If you want powershell to start as admin and run in a specific directory, even on a different drive, it is better to use the Set-Location
command. Follow these steps
- Create a ShortCutLink with the target being the powershellcommand exe.
- Leave
Start in:
blank. (Normally this starts in current working directory when blank; but we do not care.)
- Change
Target
to this with your targets for powershell and locations:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "Set-Location D:\_DCode\Main"
- Click
Advanced...
and select Run as administrator
.
- Click
OK
s out.
Don't forget the handy trick to change the colors of the shortcut from the Colors
tab. That way if you have two or more links which open powershell windows, seeing a different color can visually let you know which shell one is working in.
'
s if there are spaces in your path:powershell.exe -noexit -command "cd 'c:\a path with spaces\readme.txt'"
– Romano