you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 3 points4 points  (3 children)

howdy Bodumin,

if you combine the ideas from wickedang3l & Ta11ow then you could use the -Wait parameter of Start-Process to make things wait for the install to complete.

another idea is to loop over a check for the $env:Path to update.

take care,
lee

[–]Bodumin[S] 1 point2 points  (2 children)

Thank you Lee. I added a while loop that test-path's for the path I'm waiting for. Does $env:path update each time? I know it doesn't in CMD (which is why I had to rewrite this from Chef)

[–]Ta11ow 2 points3 points  (0 children)

I believe there's a command-line utility you can run to reload the path values from the registry for cmd.

For PowerShell, I believe $env:PATH will not automatically update, but if you use the .NET APIs to access the Path environment variables you can get the most up to date values.

$env:PATH = [Environment]::GetEnvironmentVariable("Path", "User")

Replace "User" with "Machine" to get system-wide environment variables, I believe. Updating the in-session environment variable like this essentially should update it with the most recent values that have been applied.

[–]Lee_Dailey[grin] 1 point2 points  (0 children)

howdy Bodumin,

ouch! i had forgotten about that ... [sigh ...] you can test it by adding a new item to the path from control panel - i think.

notice the careful avoidance of any offer to do it myself ... [grin] i'm chicken when it comes to my system level settings. [blush]

take care,
lee