Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way of running a powershell script by drag-n-dropping a file on it (just like you would drag-n-drop a file on a .exe file)? It would be also nice to be able to do the same thing with folders...

share|improve this question
1  
See this link. stackoverflow.com/questions/10137146/… Once you get it to start by double clicking, I think the drag and drop just auto-magically happens. –  Zoredache Aug 15 '13 at 5:59
add comment

1 Answer

up vote 1 down vote accepted

Create a Windows Explorer shortcut (In Explorer right click -> new -> shortcut). Then right-click on your shortcut and open the Properties dialog box. In the Target field enter something like this:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -noprofile -file C:\yourscriptdirectory\yourscript.ps1

Whether you need the -noexit or -noprofile options is up to you, take a look at the help to decide.

Now when you drop a file (or folder) onto this shortcut, explorer will magically pass it as the first argument to your script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.