![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||