Jump to content

Right Click File to Execute Command


ViciousXUSMC
 Share

Recommended Posts

Really small and simple code that you can modify to run any CMD parameters you want (or other script that requires a full system file path to a file)

Background:

I was looking for a way to easily change NTFS file permissions on a LOT of files, when not really finding a native way to do this in AutoIT I turned to the CMD and found Windows ICACLS.

But being CMD driven I needed to feed in the file path and so needed to find a quick and easy way to run this command intelligently based on the file I am currently selecting.

First I tried to find a way to send the path of my current selected item to AutoIt and then use it in a CMD without too much luck of figuring that out.

Then I decided to maybe try and add a Right-Click option directly from the system registry without much luck.

However when I put the two together, magic happened :)

Code:

;will take the file path from the CMD Window and place it in current clipboard
If $CmdLineRaw Then ClipPut($CmdLine[1])
;will execute CMD and dynamically place file path from clipboard
RunWait(@ComSpec & ' /k icacls "' & ClipGet() & '" /inheritance:d')
 

 

How To Use:

!!IMPORTANT!!

Take the script and compile it to an exe and move it to your "SendTo" folder.

To get to that folder you can type in the address bar 

Shell:SendTo

Put your compiled .exe into the folder and from that point forward you can right click any file and choose "Send To --> Your EXE" and it will run what ever script you have in there.

If anybody wants to add other options for a similar feature (like my original idea of selecting the file and having a hotkey activate the CMD) please feel free to add to the topic.

Edited by ViciousXUSMC
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...