![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | PATHEXT environment variable and PS1 scripts Hello: The PATHEXT environment variable in PowerShell does not include .PS1 in the list, yet you can still run PowerShell scripts without typing the .PS1 extension on script files. I assume PowerShell ignores PATHEXT? Is there a way to force the user to enter the full name of a PowerShell script, including the extension, when running a script? The benefit is that the user will know they are running a script when they think they are running an EXE (e.g., a ping.ps1 script earlier in the PATH than ping.exe). Btw, will the extension be changed to .PS2 with the next version of PowerShell? Thx! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts My preference is not to use .ps1 at all. Due to various reasons many of my scripts were converted into functions\filters and many functions\filters were converted into scripts. This was relatively painless because I never use .ps1. -- Thanks, Roman Kuzmin "ThuyLee" <tlee3@unlv.edu> wrote in message news:uIB8rLOuHHA.4476@TK2MSFTNGP03.phx.gbl... > Hello: > > The PATHEXT environment variable in PowerShell does not include .PS1 in > the list, yet you can still run PowerShell scripts without typing the .PS1 > extension on script files. I assume PowerShell ignores PATHEXT? > > Is there a way to force the user to enter the full name of a PowerShell > script, including the extension, when running a script? > > The benefit is that the user will know they are running a script when they > think they are running an EXE (e.g., a ping.ps1 script earlier in the PATH > than ping.exe). > > Btw, will the extension be changed to .PS2 with the next version of > PowerShell? > > Thx! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts ThuyLee wrote: > Hello: > > The PATHEXT environment variable in PowerShell does not include .PS1 in > the list, yet you can still run PowerShell scripts without typing the > .PS1 extension on script files. I assume PowerShell ignores PATHEXT? > > Is there a way to force the user to enter the full name of a PowerShell > script, including the extension, when running a script? > > The benefit is that the user will know they are running a script when > they think they are running an EXE (e.g., a ping.ps1 script earlier in > the PATH than ping.exe). > > Btw, will the extension be changed to .PS2 with the next version of > PowerShell? > > Thx! Well, you could consider adding a library or header to each script to determine if it was called properly, if not, exit, or at least exit with a message that looks like a real PowerShell generated error. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts > My preference is not to use .ps1 at all. Interesting, so you use a different extension, or no extension at all? |
My System Specs![]() |
| | #5 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts I use no extension at all. BTW, different extensions are not allowed for PS scripts. -- Thanks, Roman Kuzmin "ThuyLee" <tlee3@unlv.edu> wrote in message news:uf%23lSKRuHHA.4788@TK2MSFTNGP05.phx.gbl... >> My preference is not to use .ps1 at all. > > Interesting, so you use a different extension, or no extension at all? |
My System Specs![]() |
| | #6 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts I forgot to mention ability to use an alias for any command at any moment (optionally taking scope into account). I believe aliases like 'do-something.ps1' are possible, too, but they look confusing. So, again, using extension '.ps1' in the code looks less flexible to me. -- Thanks, Roman Kuzmin |
My System Specs![]() |
| | #7 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts >I use no extension at all. On 32-bit Vista, I get a pop-up dialog box asking which program I want to use to run the script if I remove the ".ps1" extension from the script, e.g., while in the shell in the folder with the script, ".\scriptname" doesn't execute the script, it pops up the OpenWith dialog box. Does yours work differently? (Sorry for all the follow-up questions.) |
My System Specs![]() |
| | #8 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts Sorry if I did not understand your problem correctly (and BTW, I have no Vista experience yet). Are you talking about running PS scripts by PowerShell.exe 'from Windows' or invoking scripts from already running PowerShell session? I am talking about the latter case. -- Thanks, Roman Kuzmin "ThuyLee" <tlee3@unlv.edu> wrote in message news:%23yH%23cxYuHHA.4952@TK2MSFTNGP04.phx.gbl... > >I use no extension at all. > > On 32-bit Vista, I get a pop-up dialog box asking which program I want to > use to run the script if I remove the ".ps1" extension from the script, > e.g., while in the shell in the folder with the script, ".\scriptname" > doesn't execute the script, it pops up the OpenWith dialog box. Does > yours work differently? (Sorry for all the follow-up questions.) > > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: PATHEXT environment variable and PS1 scripts > Are you talking about running PS scripts by PowerShell.exe 'from Windows' > or invoking scripts from already running PowerShell session? I am talking > about the latter case. Having an interactive PowerShell shell open (not CMD), then executing ".\scriptname" with no extension on the scriptname and not prefacing with "powershell.exe ..." first. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| how to set system's environment variable permanently | PowerShell | |||
| environment variable not seen | Software | |||
| Path Environment Variable - Vista 64-bit | Vista General | |||
| how to set environment variable where name is not a-z nor A-Z | PowerShell | |||
| how to set environment variable where name is not a-z nor A-Z | PowerShell | |||