Shell extension on Windows 8.1 - shell

I wrote a little command-line utility in C++ which I compiled and copied into a location in the system path. I then added the following registry entries. When I right-click a TXT file, the pop-up context menu shows the usual "Open" and "Edit" but also "DoSomething" and "SomethingElse". Selecting either sends the path of the file just clicked to the utility, which processes the file.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\txtfile\shell]
[HKEY_CLASSES_ROOT\txtfile\shell\cmd2]
#="&DoSomething"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd2\command]
#="DoSomething.exe 0 %1"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd3]
#="&SomethingElse"
[HKEY_CLASSES_ROOT\txtfile\shell\cmd3\command]
#="DoSomething.exe 1 %1"
This works great on Windows XP...but try as I might, I cannot get the context menu entry "DoSomething" to appear on Windows 8.1. And advice on how to modify the registry entries or use another method for 8.1?

Related

How to get that terminal button on right click?

How to get the terminal button on right click on widows?
The btn looks like this
Terminal Btn
On click of that btn, it opens the terminal.
Termianl
Windows Terminal Preview v1.1.1671.0 and later installers put the Windows Terminal in the context menu.
https://github.com/microsoft/terminal/releases/tag/v1.1.1671.0
But if you have an older version, you need to update the Windows Registry.
Create a wterminal.reg text file and put the following code in it and then run it. Also, make sure paths to wt.exe and wt_32.ico files are correct on your system. You can change those paths according to your system.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
#="Windows terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\terminal\\wt_32.ico"
[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
#="%LOCALAPPDATA%\\Microsoft\\WindowsApps\\wt.exe"
Warning: Be careful and make sure you have a backup of the Windows Registry before applying any changes.
Here you can find more information about it: https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461

Windows Explorer Shell Extension for double click

Is there a way to change the default application that opens all files under specified directory on Windows Explorer double click event?
For other folders I want files to be opened by standard applications.
Implement a IContextMenu shell extension. Register it under HKCR\*\ShellEx and add the MayChangeDefaultMenu key to the CLSID registration.
You must create and register both a 32-bit and a 64-bit extension on 64-bit Windows.
When a file is double-clicked Explorer will load the extension and you can add a new default menu item if the file(s) in the dataobject fulfil your criteria. This will have a small system-wide performance impact.

Add java argument to windows right click? [duplicate]

How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen).
The simple way, for simple functionality, is you can add an entry in the registry :
HKEY_CLASSES_ROOT\<file type>\shell\<display text>\command
Where <file type> is the files that this context menu should apply to i.e. *, .mdb, .doc
and
<display text> what you want to show in the context menu.
Then add the default string as a path to the application you want to launch from the context menu, and you can use %1 to refer to the currently selected file i.e. for MS Access I use :
HKEY_CLASSES_ROOT\*\shell\MS Access 2000\command
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "%1"
This then adds a context menu item for any file I select (hence the *), which allows me to launch it in MS Access 2000.
Of course, always back up your registry before hacking it.
Your program could do this during install, or on first run.
You could also package the java program in an installer like NSIS and you could use NSIS script to generate explorer context menu

How to change the path for "run command" "notepad"?

Where is in the registry the path executed when I run the "notepad" command in windows "Start->run command" interface? I want to change it for notepad++ (it is required so, although could look not really good)
If you are like me you use windows run command all the time. I hate using the mouse to point and click a shortcut on the start menu. WIN-R are probably the two most over used keys on my keyboard. After thinking about if awhile I hunted down how the run command works. It turns out that it makes a call to ShellExecute, which I guess is not too surprising. The next thing I wanted to find out was exactly how the commands are resolved. The following is an ordered list of how they are resolved ([1]):
The current working directory
The Windows directory (no subdirectories are searched)
The Windows\System32 directory
Directories listed in the PATH environment variable
The App Paths registry key
Naturally the next thing I wanted to do was customize existing commands or add new commands so I do not have to type as much (standard lazy approach). After examining my options which were to put the executable in one of those paths (since it only locates executables and not shortcuts), modify the path environment variable or add a key to App Paths. The App Paths option seems to be the easiest and most flexible to me. Here is a layout of what you need to do to add an App Paths entry ([1]):
HKEY_LOCAL_MACHINE-->
SOFTWARE-->
Microsoft-->
Windows-->
CurrentVersion==>
App Paths-->
file.exe-->
(Default) = The fully-qualified path and file name
Path = A semicolon-separated list of directories
DropTarget = {CLSID}
Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. I cannot guarantee that problems resulting from modifications to the registry can be solved. Use the information provided at your own risk.
The minimum needed to add a new entry is to add the key file.exe where file is the string you want to type into the run command and to add the Default entry which is the fully-qualified path to the file you want to execute. Note that even it the file you are going to reference isn't an exe file you still need to put the .exe on the key. Here is a sample registry file that I created to add a shorter keyword for Internet Explorer:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\ie.exe] #="C:\Program Files\Internet Explorer\iexplore.exe"
After entering that entry into the registry I can simply type “ie” at
the run command to open internet explorer.
Here is a list of some common commands I use at the run command:
cmd – Command prompt winword – Microsoft Word excel – Microsoft Excel
outlook – Microsoft Outlook iexplore – Internet Explorer firefox –
Mozilla Firefox notepad – Notepad compmgmt.msc – Computer Management
Console control appwiz.cpl – Add/Remove programs dialog mstsc –
Microsoft Terminal Service Client regedit – Registry Editor
…
If there is some program that I find myself using all the time I figure out what the run command is for it and if there is not a short easy one I add one to my App Paths as described above. Does anyone else have some other common run commands they use?

Does adding item to Windows right-click menu through registry resolve target shortcuts?

I've added a Windows right-click menu item by adding registry keys to HKCR\*\shell, where the command is of the form "path\to\my\program.exe" "params before" "%1" "params after". It seems that, if the user right-clicks on a shortcut (.lnk file), Windows is resolving the shortcut and passing the target file's path in as %1. Does anyone know where this is documented? This is used on Windows 7 and Windows XP machines.
Thanks!
I don't know if it is documented anywhere but it makes sense if you think about it. 99% of the time you want to see the context menu for the target, for a batch file for example it will show the (default) open verb and the edit verb. If the shortcut implementation did not do this then the context menu would be pretty useless since it would only contain commands related to the .lnk file (Cut, Copy, Delete and Properties)
If you also register a verb under HKEY_CLASSES_ROOT\lnkfile\Shell, that verb should have the path to the .lnk when executed.

Resources