A partial solution for the problem would be at least an ability to open command window in a required directory and there are many known ways to do that. For example, Add Command Prompt Here Shortcut to Windows Explorer has a comprehensive list of such variants. My choice was to edit Windows registry file.
Note: Editing the registry file is dangerous and good practice is to try every change you are going to do in a virtual machine first.
Copy the following text into a text file:
Windows Registry Editor Version 5.00save the file with "reg" extension, then double click it to install the new keys. You can download the OpenDirInCmd.reg file ready for using.
[HKEY_CLASSES_ROOT\Directory\shell\Open in cmd]
@="Open in cmd"
[HKEY_CLASSES_ROOT\Directory\shell\Open in cmd\command]
@="cmd.exe /k cd %1"
In addition, I created an option which is slightly different from the previous one. It opens command prompt window by right click on any file in a directory:
Windows Registry Editor Version 5.00It's in the file OpenInCmd.reg.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open in cmd]
@="Open in cmd"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open in cmd\command]
@="cmd.exe /k"
A close variant for running an executable file in cmd window is "Send to Toys" from http://www.gabrieleponti.com. It adds an option "Command Prompt" to the context menu "Send To". Using it on exe file ends up with open cmd window in corresponding directory and the chosen exe file name typed in the prompt, so the only move left to run the program is to press Enter. I personally decided to mess a little bit directly with the registry:
Windows Registry Editor Version 5.00I put it in the file RunInCmd.reg. Right click on an exe file, then choose "Run in cmd" option - it opens cmd window, runs the program from its directory and the cmd window stays open after the program termination:
[HKEY_CLASSES_ROOT\exefile\shell\Run in cmd]
[HKEY_CLASSES_ROOT\exefile\shell\Run in cmd\command]
@="cmd.exe /k \"%1\""
Similarly for batch files:
Windows Registry Editor Version 5.00I saved it in the file RunBatInCmd.reg.
[HKEY_CLASSES_ROOT\batfile\shell\Run in cmd]
[HKEY_CLASSES_ROOT\batfile\shell\Run in cmd\command]
@="cmd.exe /k \"%1\""
One thing which can be helpful: in order to see what really comes with the parameter "%1" just insert "echo" command before it:
Windows Registry Editor Version 5.00It's in the file RunInCmdecho.reg.
[HKEY_CLASSES_ROOT\exefile\shell\Run in cmd]
[HKEY_CLASSES_ROOT\exefile\shell\Run in cmd\command]
@="cmd.exe /k echo \"%1\""
So the main problem is solved, but for the sake of curiosity I'm still looking for a context menu option when right click is done on empty space in Explorer - tweaking "Directory\Background\..." in the registry has not helped yet.
0 comments:
Post a Comment