Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Right-click execute scripts ?

Reply
 
Old 07-12-2006   #1 (permalink)
MoiMeme


 
 

Right-click execute scripts ?

Hi,

have installed PowerShell

How can I have scripts auoexecute whith a right-click->execute action ( as
can be achieved with others scripts)
Seem the install doens't set actions to be performed on these scripts

TIA !



My System SpecsSystem Spec
Old 07-12-2006   #2 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Right-click execute scripts ?

"MoiMeme" <antispam@no.spam> wrote in message
news:uhwHbCbpGHA.524@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> have installed PowerShell
>
> How can I have scripts auoexecute whith a right-click->execute action ( as
> can be achieved with others scripts)
> Seem the install doens't set actions to be performed on these scripts
>
> TIA !
>


In general, you can't. The primary reason is that this is part of the
security measures to minimize opportunities for attachment execution. In
general, it also is not a very useful thing for PS scripts since most of
their value comes from use with other PS tools in a chain.

There ARE of course some situations where it would be useful to run scripts
by themselves. I've got one workaround of my own that I use to create a
launcher on a case-by-case basis for specific PowerShell scripts. The
workaround is a WSH script, New-PS1Link.vbs. You can drag/drop PS1 scripts
onto New-PS1Link, and shortcuts to the dropped scripts that correctly launch
them with PowerShell will be created in the same folder as the PS1 scripts.


My System SpecsSystem Spec
Old 07-12-2006   #3 (permalink)
Greg Borota


 
 

Re: Right-click execute scripts ?

PowerShell guys decided that's bad from a security point of view. I'd leave
the default behavior as it is. That said, you could change/customize that
behavior in many ways, one being Open With->Choose Program-> etc...

Greg

"MoiMeme" <antispam@no.spam> wrote in message
news:uhwHbCbpGHA.524@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> have installed PowerShell
>
> How can I have scripts auoexecute whith a right-click->execute action ( as
> can be achieved with others scripts)
> Seem the install doens't set actions to be performed on these scripts
>
> TIA !
>



My System SpecsSystem Spec
Old 07-12-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Right-click execute scripts ?

"MoiMeme" <antispam@no.spam> wrote in message
news:uhwHbCbpGHA.524@TK2MSFTNGP05.phx.gbl...

Hit reply too soon.

I've attached the New-PS1Link.vbs script with ".foo" appended to the name.
Script content is also shown below for the attachment-challenged.

===============================
'New-PS1Link.vbs

Dim PsPathKey
PsPathKey = "HKLM\SOFTWARE\Microsoft\PowerShell\" _
& "1\ShellIds\Microsoft.PowerShell\Path"
Dim WshShell: Set WshShell = CreateObject("WScript.Shell")
Dim PsPath
PsPath = WshShell.RegRead(PsPathKey)

Dim uarg, uargs
Set uargs = WScript.Arguments.UnNamed
For Each uarg in uargs
' Our shortcut is named after the script:
Dim lnk
Set lnk = WshShell.CreateShortcut(uarg & ".lnk")
' The target has to be powershell.exe itself:
lnk.TargetPath = PsPath
lnk.Arguments = "-NoLogo -NoExit & " _
& """'" & uarg & "'"""
lnk.Description = "Invoke MSH script " & uarg
lnk.Save
Next




My System SpecsSystem Spec
Old 07-12-2006   #5 (permalink)
MoiMeme


 
 

Re: Right-click execute scripts ?

I understand. Have done it for my vbs files. By default they open in
notepad. To execute them I have to right-click and select a particular
command.

But then how does one use the ps1 files that are florishing on the web ?
TIA

"Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> a écrit dans le message
de news: eLsArRbpGHA.4912@TK2MSFTNGP05.phx.gbl...
> "MoiMeme" <antispam@no.spam> wrote in message
> news:uhwHbCbpGHA.524@TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> have installed PowerShell
>>
>> How can I have scripts auoexecute whith a right-click->execute action (
>> as can be achieved with others scripts)
>> Seem the install doens't set actions to be performed on these scripts
>>
>> TIA !
>>

>
> In general, you can't. The primary reason is that this is part of the
> security measures to minimize opportunities for attachment execution. In
> general, it also is not a very useful thing for PS scripts since most of
> their value comes from use with other PS tools in a chain.
>
> There ARE of course some situations where it would be useful to run
> scripts by themselves. I've got one workaround of my own that I use to
> create a launcher on a case-by-case basis for specific PowerShell scripts.
> The workaround is a WSH script, New-PS1Link.vbs. You can drag/drop PS1
> scripts onto New-PS1Link, and shortcuts to the dropped scripts that
> correctly launch them with PowerShell will be created in the same folder
> as the PS1 scripts.
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
In Powershell execute scripts on many remote machines ,Monitor and report back General Discussion
Execute scripts in current scope? PowerShell
Execute PowerShell Scripts via http url requests PowerShell
How to execute (perl) scripts in Powershell without DOS box PowerShell
AD LogOn Scripts Execute permissions Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46