![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | associate .ps1 filetype with powershell What would be the best way to associate the .ps1 filetype with powershell? So that doubleclicking a .ps1 will result in execution of the script? Generally I would like use .ps1 as a replacement for .bat on my local dev machine. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: associate .ps1 filetype with powershell Let me describe my way of doing this for scripts that do not require investigation of console output. I create this association by PowerShell (well, FType) command (unfortunately it will not work if a path contains '): ## Associate .ps1 files with PowerShell.exe cmd /c @" FType Microsoft.PowerShellScript.1=$pshome\powershell.exe -noexit . "'%1'" %* ; exit "@ Advantages: *) if a script succeeds its console window is closed, so that I do not have to do it manually. *) if a script fails its console is not closed because of -noexit and not yet executed final 'exit' statement. Now I can: - read the output (if any) and error messages; - investigate current variables, environment and etc (note: the script was dot-sourced); - fix some (outside) problems and re-run the script with full set of original parameters simply by 'r' command which is a default alias of Invoke-History (or by 'r 1' command if I ran some other commands) I found this technique very useful for many tasks. -- Thanks, Roman Kuzmin PowerShellFar and FarNET: http://code.google.com/p/farnet/ "Robert Ludig" <schwertfischtrombose@gmx.de> wrote in message news:1183638063.106052.164580@k79g2000hse.googlegroups.com... > What would be the best way to associate the .ps1 filetype with > powershell? So that doubleclicking a .ps1 will result in execution of > the script? Generally I would like use .ps1 as a replacement for .bat > on my local dev machine. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: associate .ps1 filetype with powershell Sorry, how where do I put that configuration string you mentioned? On 5 Jul., 14:52, "Roman Kuzmin" <z...@z.z> wrote: > Let me describe my way of doing this for scripts that do not require > investigation of console output. > > I create this association by PowerShell (well, FType) command (unfortunately > it will not work if a path contains '): > > ## Associate .ps1 files with PowerShell.exe > cmd /c @" > FType Microsoft.PowerShellScript.1=$pshome\powershell.exe -noexit . "'%1'" > %* ; exit > "@ > > Advantages: > *) if a script succeeds its console window is closed, so that I do not have > to do it manually. > *) if a script fails its console is not closed because of -noexit and not > yet executed final 'exit' statement. Now I can: > - read the output (if any) and error messages; > - investigate current variables, environment and etc (note: the script was > dot-sourced); > - fix some (outside) problems and re-run the script with full set of > original parameters simply by 'r' command which is a default alias of > Invoke-History (or by 'r 1' command if I ran some other commands) > > I found this technique very useful for many tasks. > > -- > Thanks, > Roman Kuzmin > PowerShellFar and FarNET:http://code.google.com/p/farnet/ > > "Robert Ludig" <schwertfischtromb...@gmx.de> wrote in message > > news:1183638063.106052.164580@k79g2000hse.googlegroups.com... > > > > > What would be the best way to associate the .ps1 filetype with > > powershell? So that doubleclicking a .ps1 will result in execution of > > the script? Generally I would like use .ps1 as a replacement for .bat > > on my local dev machine.- Zitierten Text ausblenden - > > - Zitierten Text anzeigen - |
My System Specs![]() |
| | #4 (permalink) |
| | Re: associate .ps1 filetype with powershell > Sorry, how where do I put that configuration string you mentioned? Put it into the file, say, Install-Association.ps1 and run it once. Mind unwanted line break on wrapping in the text. -- Thanks, Roman Kuzmin PowerShellFar and FarNET: http://code.google.com/p/farnet/ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How can I remove ALL the programs a filetype opens with?, Make a filetype not to open | General Discussion | |||
| How can I remove ALL the programs a filetype opens with?, Make a filetype not to open | Vista General | |||
| How do I change filetype icons? | Vista General | |||
| Changing Icon FileType | Vista General | |||
| filetype | Vista General | |||