Windows 7: Opening Command Prompt with Shortcut Icon in Directory of Icon

command lineiconskeyboard shortcutswindows 7

I am trying to open the command prompt for the directory that the shortcut icon is currently located in. However, I want to be able to move this given icon to another directory (using my mouse to drag it into a new folder in the Windows Explorer) and be able to double click it to open the command prompt in that new directory.

I am wanting to use something along the lines of "cmd /k "cd cwd" & {other commands}" where cwd would give the current working directory that the icon is located in.

I am having issues because I cannot just use 'cmd-here' in the target line.

Any suggestions?

This is the current configuration I have.

enter image description here

Best Answer

Force a CMD shortcut to open in a directory the shortcut resides

Simply put %cd% into the Start in: field and this will ensure the cmd.exe opens in whatever folder the shortcut resides at the time of execution—I've tested this and confirmed it to work just as described (and requested) on both Windows 7 and Windows 10.

enter image description here


Further Resources

  • cd

    Display the current drive and directory:

    C:\Work> ECHO "%CD%"
    
Related Question