Radish Posted May 18, 2015 Share Posted May 18, 2015 (edited) HI,I'm working on script (compiled to executable) that will be launched by a right-click Context Menu item in Windows Explorer. Basically the exe looks for highlighted/selected folders and files in Explorer and then writes to a text file the full paths of the folders/files that were selected when the exe is launched. If I launch the exe manually then it works fine - does what it is meant to do. However, if I launch the exe from the Context Menu it messes up big-time. For example let's say I have two folders and one file selected in Explorer then use the Context Menu to launch the exe then instead of launching the exe once the exe is launched three times (once for each of the number of items that have been selected in the Explorer window). And, of course, I have three duplicate enteries in the output text file for each of the Folders\Files selected.It can't be the exe that is doing this - it must be something that Windows OS is doing.The entries that I made in the registry to give the right-click Context Menu (and subsequently exported from the registry are as follows):Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\Checksums][HKEY_CLASSES_ROOT\*\shell\Checksums\command]@="\"E:\\AutoIT Scripts\\Testing\\Checksums_x64.exe\""[HKEY_CLASSES_ROOT\Directory\shell\Checksums][HKEY_CLASSES_ROOT\Directory\shell\Checksums\command]@="\"E:\\AutoIT Scripts\\Testing\\Checksums_x64.exe\""Does anyone know why this multiple launching of the exe file is happening and how to prevent it? (If it only launched the exe file once then everything would be fine.) Edited May 18, 2015 by Radish Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
mikell Posted May 18, 2015 Share Posted May 18, 2015 This occurs because the command in the context menu is applied to any of the selected objects (same as context menu "create a shortcut")You could try _Singleton() Link to comment Share on other sites More sharing options...
Radish Posted May 18, 2015 Author Share Posted May 18, 2015 Mikell, you are Brilliant! Thankyou! Tthat worked!I'm actually surprised that it worked and don't understand how it did. The exe is designed to launch, write the output file, then immediately exit (and it does all that very quickly) - so it I'm suspecting that it probably wasnt the case of multiple instances of the exe running at the same time. So I don't understand how _Singleton() actually worked to cure this problem. (Maybe it's just that things are happening so fast that that the other launches of the exe are actually occuring before the first launch of the exe has a chance to fully exit. Or maybe that is just wrong thinking on my part because I don't really understand how _Singleton() works.)In any case I've now found out that my right-click context menu doesn't work in some situtations, depending on what is selected. Ah, one step at a time I suppose.Thanks again. Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
mikell Posted May 18, 2015 Share Posted May 18, 2015 Of course you may have several instances of your exe launched almost simultaneously - it's the reason why _Singleton() works, allowing only one instance to run Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now