I'd like to run this batch file (setenv.cmd) when I right click on any folder:
@echo off
SET CPLUS_INCLUDE_PATH=C:\mingw32\include;C:\mingw32\lib\gcc\mingw32\4.9.2\include;
SET PATH=%PATH%;C:\Archivos de programa\7-Zip;C:\Archivos de programa\WinRAR;C:\usr\bin;C:\msys\1.0\bin;C:\gtk2\bin
SET PKG_CONFIG_PATH=C:\gtk2\lib\pkgconfig;C:\usr\lib\pkgconfig
@echo on
I setuped my registry from this page, with the "prompt here". My question is how to open the console window from the selected directory and run my batch file?
Use &
. On Windows 8.1:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmdDD]
@="CMD + setenv"
[HKEY_CLASSES_ROOT\Directory\shell\cmdDD\command]
@="cmd.exe /s /k pushd \"%V\"&call \"D:\\full\\path\\to\\setenv.cmd\" \"%V\""
;
Note that all inner "
double quotes and \
reverse slashes in the data are escaped with a \
backslash. In fact, data are as follows:
==>reg query HKEY_CLASSES_ROOT\Directory\shell\cmdDD\command
HKEY_CLASSES_ROOT\Directory\shell\cmdDD\command
(Default) REG_SZ cmd.exe /s /k pushd "%V"&call "D:\full\path\to\setenv.cmd" "%V"
Edit: cmd.exe /s /k pushd "%V"&call "D:\full\path\to\setenv.cmd"
should suffice. An additional (trailing) "%V"
is merely a remainder residue of my debugging practice (@echo %1
in the batch to ensure it works).
Resources (required reading):
- (command reference) An A-Z Index of the Windows CMD command line
- (additional particularities) Windows CMD Shell Command Line Syntax
- (
&
special page) Redirection