|
Re: Can you drag-n-drop a file on top of a PS script to run the script? Thanks, this works great and also works as a Send To item.
JIm
William Stacey [C# MVP] wrote:
> There may be a better way, but this worked for me so far:
>
> 1) Right-click/New Shortcut on desktop.
> 2) Enter the target like so: powershell.exe "&{c:\bin\testit.ps1 $args}"
> 3) Change testit.ps1 to be your target script you want to run.
> 4) The file name is passed as parms to the command, which is passed as first
> parm to the script. It gets funky to reason about.
> 5) When you drag another script onto this icon, it should pass the file name
> to the script and you can then do what you want with that file name.
>
> I don't think the first way of draging a script ontop of another script will
> work as that is like dragging a txt file onto another txt file which also
> does nothing unless there is some hack.
>
> testit.ps1
> -----------------------------------------------------------------
> param([string]$path = $(throw "Path name must be specified."))
> echo "Len:" $args.length
> $args
> cat $path
> read-host -prompt "Hit Enter"
> |