I am trying to create a shortcut link which will run/open Command Prompt (cmd) as Administrator having present working directory (PWD) set as the supplied folder path.

What I have done:

Created a batch file with following contents, and saved as "D:\Open Admin Command Prompt.bat":

@echo off
cmd /k cd "%1"
echo on

Then created its shortcut in "C:\Users\Nikunj\AppData\Roaming\Microsoft\Windows\SendTo".

Then I opened the shortcut's properties -> "Shortcut" tab/page.

Set "Target" to "D:\Open Admin Command Prompt.bat" %1

(Please notice %1 at the end of the target path)

Then, clicked "Advanced" button to open "Advanced Properties" dialog box, and checked "Run as administrator"(, and closed all open dialog boxes with OK button).

Now, I am trying to open Command Prompt as Administrator by Context menu of "D:\Nikunj" folder -> Send to -> Open Admin Command Prompt.bat. The Command Prompt is opening as Administrator, but the PWD is not being set to "D:\Nikunj", instead, Command Prompt is showing error "The system cannot find the path specified.", it means %1 is not being recognized as an argument to the shortcut.

So, what should I write in place of %1, or please tell me if there is any other method.


Now this is working for system drive as well as other drives.

Created a batch file with following contents, and saved as "D:\OpenAdminCommandPrompt.bat":

@echo off
set v=%~1
cd "%v%"
@echo on


  1. Created a shortcut in %UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo folder.
  2. Set its target/location to: cmd.exe /k D:\OpenAdminCommandPrompt.bat. (I set batch file's name without any space because otherwise text after the space would be considered as 2nd argument to the cmd.exe.)
  3. Opened shortcut's property, clicked on "Advanced" button to open "Advanced Properties" dialog box, and checked "Run as administrator" and saved.
  4. Set this shortcut's name as Open Admin Command Prompt.lnk.

Now when right-clicking on any folder -> opening Send To menu -> clicking on "Open Admin Command Prompt", will open the folder in command prompt window with admin rights!

  • You should have edited your original answer instead of posting a second answer. Can you confirm - is the original answer now redundant? – suspectus Oct 19 '15 at 22:04
  • Original answer can not be said redundant, because (1) the previous/now_deleted (by @Sathya) was not a full proof according to what I was trying to achieve with it, and (2) it was done with a slightly different approach. – Nikunj Bhatt Oct 21 '15 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.