In my form load I have this (I am leaving out the part about checking the version because it works fine):
- if ([System.Windows.Forms.MessageBox]::Show("There is a newer version of the HelpDesk Tool available.`nWould you like to update it now?", "Updated Version Available", [System.Windows.Forms.MessageBoxButtons]::YesNo) -eq "Yes")
- {
- \\MyFileServer\HelpDeskTool\Updatetool.ps1
- }
- Get-Process "HelpDesk Tool" | Foreach-Object { $_.CloseMainWindow() | Out-Null } | stop-process –force
- sleep 1
- copy "\\MyFileServer\HelpDeskTool\HelpDesk Tool.exe" $env:USERPROFILE"\Desktop\"
- invoke-item "$env:USERPROFILE\Desktop\HelpDesk Tool.exe"
I had read a few things that basically said to run the update script from the start and have it call the Main script. I can do this but was hoping to find a way to do it the way I originally wanted.....if possible.
After some searching I tried this:
- if ([System.Windows.Forms.MessageBox]::Show("There is a newer version of the HelpDesk Tool available.`nWould you like to update it now?", "Updated Version Available", [System.Windows.Forms.MessageBoxButtons]::YesNo) -eq "Yes")
- {
- start-job -filepath \\MyFileServer\HelpDeskTool\Updatetool.ps1
- }
What would be the best way to set something like this up?
Thanks,
Scott