0

I added a new item to context menu lets call it "Test", what I want to do is that when i right click on a file or folder, then select this "Test" button from context menu, it will run a powershell script that copies file/folder to locations based on file extensions or folder names.

I need help on [How to pass the mouse selected item into my powershell script ? ]

I am not sure if I made myself clear, example will be if I select file.txt by mouse then right click on it then select "TEST" button from context menu to run my powershell script for copying this file to a location, how can I pass this selected "file.txt" with full path into my powershell script?

If powershell wont work, how about vbs?

Context menu modification will be on

for Folder Menus
HKEY_CLASSES_ROOT\Directory\shell 

for All File Types

HKEY_CLASSES_ROOT\*\shell 
Root Loop
  • 3,004
  • 9
  • 46
  • 72
  • How are you adding the context menu item? – Etan Reisner Feb 18 '15 at 03:32
  • And what content are you putting there? What do your keys and values look like? Have you looked at other entries in those locations? – Etan Reisner Feb 18 '15 at 03:36
  • I added a new key called "test" then a subkey called "command" with value of "powershell.exe + Location to my script", I dont know how to pass the selected item into my script – Root Loop Feb 18 '15 at 03:39
  • Do you have any other entries in those locations you can look at? Because they should have what you need in them. – Etan Reisner Feb 18 '15 at 03:45
  • http://superuser.com/questions/136838/which-special-variables-are-available-when-writing-a-shell-command-for-a-context/473602#473602 – Etan Reisner Feb 18 '15 at 03:46
  • Thanks for your help. I think this is the one close to what I need. http://stackoverflow.com/questions/12125959/power-shell-how-to-send-middle-mouse-click – Root Loop Feb 18 '15 at 03:49
  • That answer is about *sending* a mouse click to something. See the superuser question I linked it discusses the arguments available to scripts run as `command` for a menu item handler. – Etan Reisner Feb 18 '15 at 03:55
  • Yes, I am looking into it now. it will be a great help for sure. Thanks – Root Loop Feb 18 '15 at 04:00

0 Answers0