Adding batch script to Windows 8 context menu - windows

I saw some other questions about this here, but still got nothing working for what I want.
I want to right click the empty space of a folder, and see a menu for executing a batch file for the current folder.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\treeFiles]
#="Execute treeFiles"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\treeFiles\command]
#="C:\treeFiles.bat \"%V\""
#="C:\\treeFiles.bat -d \"\"%V\"\""
With the above, I can only see the item when I right-click a folder (not the empty space), and the batch will execute relative to it's self path, not the current folder.
Any idea how to fix?

Use this instead:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\treeFiles]
#="&Execute treeFiles"
"Icon"="%SystemRoot%\\System32\\shell32.dll,71"
[HKEY_CLASSES_ROOT\Directory\Background\shell\treeFiles\command]
#="C:\\treeFiles.bat \"%V\""

Related

question about parameter on add line to the context menu

I wrote the following lines in windows registry...
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\exefile\shell\runDOT]
#="run in DOT environment"
[HKEY_CLASSES_ROOT\exefile\shell\runDOT\command]
#="\"D:\\T00Ls\\x64\\DOT\\DOT.exe\" \"%1\""
that works like a charm!
Through parameter %1, any executable file that is selected through the context menu in explorer, is loaded by DOT.exe
To load a second file with the same name, but with a different extension, how will be the variable that I should use?
When creating context menu entries in the registry, what variables can be passed to the commands?
rmk.: I found the following doc, but not helped me.
Extending Shortcut Menus

Why double clicking opens application but does not load file?

I made an application for editing .cue files. If I use a .bat file containing
CueEditor.exe Ah.cue
line, it opens application and loads file properly; so it seems command line arguments are able to be passed properly; but double clicking on a .cue file opens application without loading file.
.reg files which include registry keys which are created by the setup program for registering the application default for .cue files are these:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.cue]
#="CueFile"
and
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CueFile]
[HKEY_CLASSES_ROOT\CueFile\Defaulticon]
#="\"C:\\Program Files\\Cue Editor\\CueEditor.ico\""
[HKEY_CLASSES_ROOT\CueFile\shell]
[HKEY_CLASSES_ROOT\CueFile\shell\open]
[HKEY_CLASSES_ROOT\CueFile\shell\open\command]
#="\"C:\\Program Files\\Cue Editor\\CueEditor.exe\" \"%1\""
What is wrong?
By the way, I use Windows XP.
At last I found answer after which I had ensured that the registry settings are appropriate. Windows passes the path as string but puts quotation marks of each side like this:
"C:\Documents and Settings\ABC\Desktop\AH.cue"
and if it is being thought that can be used as path like bare C:\Documents and Settings\ABC\Desktop\AH.cue string, it does not work. Quotation marks at the ends should have been cleaned first.

CMDer / ConEmu - Explorer current directory location

I have right click integration with CMDer to pop up a console, but it's defaulting to my user directory instead of the directory I performed the right click in. If you press Win+R and run cmd, or hold shift and right click to open a command prompt from the context menu; the command prompt opens up at that location. I've been able to get CMDer/ConEmu to pick up on that use it, however it seems to be a plain command prompt, no additional features supported.
Ideally I could elevate to run as admin, have tried -new_console:a in the integration settings menu with no luck.
You can go to Settings > Integration and set this in command field (upper section).
{bash} -cur_console:n:d:"%V"
%V is used to pass the current directory you are in.
After that you just need to hit the Register button in the upper section.
AFAIK CMDer forced your active directory to the user profile. Bare ConEmu do not do that. That's because cmder initialization scripts.
However without precise description hire do you set up your menu item (screenshot) and example of the directory you are trying it's impossible to be sure.
I solved the problem modifying the command syntax in registry. For example, it would look like that for the directories:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
You can fix this for drives as well. Don't forget about Background section so you can use the menu option from blank space in Explorer.
To run the shell in elevated mode you may add "*" (asterisk) before the command in tasks setup, like this:
Here is the full .reg file employing the fix. Just replace the path with your cmder installation and enjoy.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Drive\Background\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\Background\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Drive\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Drive\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder]
#="Cmder Here"
"Icon"="C:\\tools\\cmder\\icons\\cmder.ico"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\Cmder\command]
#="\"C:\\tools\\cmder\\Cmder.exe\" \"%V\""
P.S. It just struck me that %CMDER_ROOT env var may be used instead of the absolute path.
In my case worked by passing in the command arguments: /START "%folder%"
In the newer versions of cmder registering the right-click is enough.
Open the command prompt where cmder.exe exists. Then enter:
.\cmder.exe /REGISTER USER
In the newer version just go to Settings -> Integration -> Register -> Save Settings.
Note click the first register button of the upper section and then save the setting and its done, go to folder where you want to open the application press and hold shift key and right click and will appear ComEmu Here in dialog box.
It's for the latest versions.

Pass multiple parameters with open command

I am looking for ways to open multiple documents in a single application instance. For example, open multiple documents in a single, new gVim instance.
I had found this code on here before, but it doesn't quite do what I want.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\Shell\Open with &Vim]
[HKEY_CLASSES_ROOT\*\Shell\Open with &Vim\command]
#="\"C:\\Users\\avt\\Programs\\PortableApps\\gVimPortable\\gVimPortable.exe\" -p --remote-tab-silent \"%1\" \"%*\""
The problem is that it is giving a similar effect, but not the one I want (it opens the selected documents in an existing gVim instance, not all of them in their OWN new gVim instance). What I want is like this:
Highlight 5 documents in Explorer
Open them
A single gVim instance opens with all 5 documents as tabs
I think this would work, if only I could pass multiple arguments!
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\Shell\Open with &Vim]
[HKEY_CLASSES_ROOT\*\Shell\Open with &Vim\command]
#="\"C:\\Users\\avt\\Programs\\PortableApps\\gVimPortable\\gVimPortable.exe\" -p \"%allselecteddocuments\""
Thanks!
EDIT: I just found out I can do this by adding a custom SendTo command (create a shortcut in your SendTo folder to gVim add -p to the Target. Is there any way to do this outside of the SendTo menu?
Create a shortcut in C:\Users\\\<user>\AppData\Roaming\Microsoft\Windows\SendTo folder with ONLY the exe name.
Now you should be able to select random multiple files and use context SendTo\<shortcut> to open them with your designated exe.

Windows shell add item to context menu when click on blank part of folder

Sorry if this has been asked before, I've been looking around and it's hard to find what I want.
I know how to add a context menu item to a folder like so:
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Open Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%1\"\""
but, that only works for right clicking on a folder. I want it so that you can be inside the folder, and click a blank part of that folder and get the context menu item as well. I also tried HKEY_CLASSES_ROOT\Directory\shell as well, but it does the same.
I figured out the answer. The folder is actually Directory\Background, you have to add the empty string value of NoWorkingDirectory into it, and the %1 in the command becomes a %V
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2]
#="Open Console2 Here"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\Background\shell\console2\command]
#="C:\\Program Files\\Console\\console.exe -d \"\"%V\"\""
Source:
saviert's comment at http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista#comment-57856
Console2 rocks. I added an 'Cmd here (Console2)' item to my explorer context menu.
Save the text below in a file named open-console2.reg then open it to import it to the Windows registry.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2]
#="Cmd here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -d \"%V\"\\"
Bonus 'bash here' item (assumes you have a Console2 tab named 'bash').
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash]
#="Bash here (Console2)"
"NoWorkingDirectory"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\console2_bash\command]
#="\"C:\\Program Files (x86)\\Console2\\Console.exe\" -t Bash -d \"%V\"\\"
I think the relevant part of the TortoiseSVN installer is here. Perhaps you can figure out all the necessary registry keys from that.
None of the above worked for me.
But this does (tested on Windows 7 Pro x64):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Open console here\command]
#="u:\\users\\dave\\data\\bin\\Console2\\Console.exe cmd -r \"/k pushd %L\""
Replace the path with the path to your copy of console.exe (of course).
#Ben Voigt mentioned TortoiseSVN, you can also see WinMerge shell extension source code, or at last: create your own extension from scratch; I wanted to do something like this for XP but I have lots of other stuff to do now.
As a workaround, you can just open a folder in XP, and then select View->Explorer Bar->Folders, to have folder tree on left, and then you're able to right-click the folder (active folder gets hightlighted automatically).
Here it is if you prefer MinGW.
#!/bin/sh
reg add 'HKCR\Directory\Background\shell\sh' -d 'Open Bash window here'
reg add 'HKCR\Directory\Background\shell\sh\command' \
-d 'C:\MinGW\msys\1.0\bin\sh.exe -l'
printf 'cd -' >> ~/.profile
superuser.com/a/387273
According to my personal experience of Windows XP (SP3), you can open Console2 inside the current directory with a context menu entry using the following .reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\console2]
#="Console2 Here"
[HKEY_CLASSES_ROOT\Folder\shell\console2\command]
#="C:\Program Files\Console\console.exe -d \"%1\""
If you look at the key value inside regedit.exe , you should see:
C:\Program Files\Console\console.exe -d "%1"
instead of:
C:\Program Files\Console\console.exe -d ""%1""
The latter would open Console2 in its default start directory.
This can be achieved in XP as well.
First open the program Run with the Windows key + R,
and type Regedit in the textbox.
Press Enter.
In the Registry open the Key : HKEY_CLASSES_ROOT
and then : *
You will now see a key called : shell
Rightclick on shell and point to New.
Click in de menu on Key.
Now type a name of your choice which you want to appear in the Rightclick menu.
Rightclick on the name you chose, again point to New and click Key.
Now type : command
Click on command and in the right pane of the Registry doubleclick on (Default).
In the textbox Value Data, type the path to an application you want to open via the chosen name in the rightclick menu.
For example : "C:\Program Files\CCleaner\CCleaner.exe"
Then type after the path : %1,
and leave a space between the end of the path and %1
It should look like this :
"C:\Program Files\CCleaner\CCleaner.exe" %1
This way, it's possible to open any kind of application you want.
There's only one drawback,
you have to rightclick another file to see the chosen name with which you can open the application.
When you rightclick a folder this will not work.

Resources