Wednesday, July 6, 2016

Add option on context menu in windows

Today i will explain how to add add new option in existing context menu.
Or basically adding new button on right click in windows.

Here we will add option name "Script" on context menu.

Below are steps

Step 1: Go to run and type "regedit".





Step 2: Go to HKEY_CLASSES_ROOT



Step 3: Go HKEY_CLASSES_ROOT\* \shell and add new key. Remember we are adding to  * because this will be all the files in your system , but not to directory.




Step 4: Name the new key as "Script".



Step 5: Modify the Default file .




Step 6: Change the value data to "&Script" name.



Step 7: Create a new key inside script folder.




Step 8:Name the folder as "command"



Step 9:Modify the default file inside command folder



Step 10: Modify the value data to "C:\Python34\python.exe" "C:\Python34\harry.py" "%1"
First statement is saying that it will invoke python.exe and then it will run the harry.py file .
While %1 is the file details on which right click have been done .
In this case %1 will be command line argument to the harry.py file.




Step 11: Now it is time to test the same. Right click on any file in your system and you will see that Script on context menu.
When we click there it will execute the harry.py file and argument in this case would be "C:\Users\Harry\Desktop\video\test_file.txt"





Please comment in case any doubts.



No comments:

Post a Comment