[Serenity] Adding scripts to context menu (Windows) 01-03-2016, 01:58 PM
#1
I haven't slept in 24 hours, so naturally, I've learned a shitton and decided to post some of my info here. It's a quick tut, but I'll be outlining how to add custom scripts to your right click, or context, menu through editing registry keys.
First, open up a shell of your choice and run the regedit command. You'll get an admin prompt, so accept and continue.
From here, there's a choice we need to make. If you want a static command that shows up when clicking on your desktop, navigate to the following key:
After you're there, create a key named whatever you want the menu item to be, in this case, Steam (because I'm a fucking nerd).
After you've made the key, create a subkey named whatever you want, though I find "command" works well for organization.
Once you've made that, edit the subkey's default REG_SZ value to the full file path of whatever static program you're running.
![[Image: TZt0kDO.png]](http://i.imgur.com/TZt0kDO.png)
![[Image: cHp19cL.png]](http://i.imgur.com/cHp19cL.png)
![[Image: W5yD3yK.png]](http://i.imgur.com/W5yD3yK.png)
Elsewise, if you want the real shit, which is running a dynamic script like the one I'm detailing here (which I'll post in another thread) that takes arguments, navigate to:
Once there, go through the same key/subkey creation I outlined in the static method. The only difference is the REG_SZ key's value. Instead of something arbitrary like the steam path, you can run, say, a python script using the below value:
The reason we need the full path to everything is because the registry has no access to your PATH environment variable, which is what lets you execute python files with just "python script.py".
The second argument, the script's path name, should be in quotes, but doesn't need to be. Just good practise.
The final argument, %1, is Window's version of sys, or process, .argv[1]. Normally, it would stand as a command line argument, but in this case identifies as the selected file, which is convenient. To implement that in your code, just use the aforementioned argv array.
![[Image: e3pPCsd.png]](http://i.imgur.com/e3pPCsd.png)
![[Image: t2SU9Ua.png]](http://i.imgur.com/t2SU9Ua.png)
First, open up a shell of your choice and run the regedit command. You'll get an admin prompt, so accept and continue.
From here, there's a choice we need to make. If you want a static command that shows up when clicking on your desktop, navigate to the following key:
Code:
HKEY_CLASSES_ROOT\Directory\Background\shell\After you're there, create a key named whatever you want the menu item to be, in this case, Steam (because I'm a fucking nerd).
After you've made the key, create a subkey named whatever you want, though I find "command" works well for organization.
Once you've made that, edit the subkey's default REG_SZ value to the full file path of whatever static program you're running.
![[Image: TZt0kDO.png]](http://i.imgur.com/TZt0kDO.png)
![[Image: cHp19cL.png]](http://i.imgur.com/cHp19cL.png)
![[Image: W5yD3yK.png]](http://i.imgur.com/W5yD3yK.png)
Elsewise, if you want the real shit, which is running a dynamic script like the one I'm detailing here (which I'll post in another thread) that takes arguments, navigate to:
Code:
HKEY_CLASSES_ROOT\*\shell\Once there, go through the same key/subkey creation I outlined in the static method. The only difference is the REG_SZ key's value. Instead of something arbitrary like the steam path, you can run, say, a python script using the below value:
Code:
C:\Python27\python.exe "C:\Users\-\Desktop\Code\-\-\pomfloader.pyw" %1The reason we need the full path to everything is because the registry has no access to your PATH environment variable, which is what lets you execute python files with just "python script.py".
The second argument, the script's path name, should be in quotes, but doesn't need to be. Just good practise.
The final argument, %1, is Window's version of sys, or process, .argv[1]. Normally, it would stand as a command line argument, but in this case identifies as the selected file, which is convenient. To implement that in your code, just use the aforementioned argv array.
![[Image: e3pPCsd.png]](http://i.imgur.com/e3pPCsd.png)
![[Image: t2SU9Ua.png]](http://i.imgur.com/t2SU9Ua.png)
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.















![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)



![[Image: 9JVyFsC.png]](http://i.imgur.com/9JVyFsC.png)









