Top
JohnKlann / Uncategorized  / Start Powershell as Administrator in a Specific Directory

Start Powershell as Administrator in a Specific Directory

This is a continuation of a previous post on starting a process in powershell as administrator. QT Powershell #4

In this post the focus will be on lunching powershell as administrator to a specific directory.

  1. Open windows run prompt (win+R)
  2. Enter following command:
    1. powershell start-process powershell -verb runas -ArgumentList “{-NoExit -Command cd c:\tmp | clear}”
  3. In this case it will run Powershell as admin and change directory to my c:\tmp directory then clear the new shell.

Now I know that is probably is the most convenient thing way of doing this, so if you normally want to get to the same directory we can speed up the process by taking advantage of a windows shortcut.

  1. Go to your desktop or where ever you want to store your shortcut then right click > new > shortcut.
  2. In the “Type the location of the item:” field enter powershell. Then click Through the rest of the prompts.
  3. Next right click on your new shortcut and select properties.
  4. In the Target field of the “Shortcut tab” delete everything in it and paste your powershell start command (ex see previous step 2.1)
  5. Now for the most convenient part in the “Shortcut Key” field press a hotkey combination that you would like to use to execute the powershell command.
    1. ex: Ctrl+Alt+P
  6. Finally in the “Run” field use the drop down menu and select “minimized”, then apply ok.

Now you can just press your hotkey and boom you have powershell as admin in a specific directory.