Hi,
Let's say I have a compiled PS exe stored on the user's C drive.
When they launch the exe, it first does a version check.
What I would like to do is automatically copy a newer version from a UNC path to replace the local exe if the version check fails.
However if I do the version check, I cannot automatically do a copy command if the version check fails because the exe is in use.
What's the best way to spawn a task that does the copy successfully please?
Thanks
David
Auto update an exe on failed version check
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Auto update an exe on failed version check
First, the process you're describing won't work. As you mention, the executable is already running.
Now, it may be possible to:
1. Create a background process (if the older version exists) to run outside the executable which could terminate the running process.
2. Then uninstall the executable.
3. And finally, run the installer for the new application.
Now, it may be possible to:
1. Create a background process (if the older version exists) to run outside the executable which could terminate the running process.
2. Then uninstall the executable.
3. And finally, run the installer for the new application.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: Auto update an exe on failed version check
Write a cmd file (copyapp.cmd) that copies the app file and starts it again. Execute with CMD /c copyapp.cmd and exit immediately.
You may need some kind of delay in there. Timeout or Start-Sleep if you use PowerShell.
You can of course do the same thing in powershell with a powershell script. Erase the cmd or ps1 one when you app starts and it exists to avoid clutter.
Pretty low tech in a way but it works.
You may need some kind of delay in there. Timeout or Start-Sleep if you use PowerShell.
You can of course do the same thing in powershell with a powershell script. Erase the cmd or ps1 one when you app starts and it exists to avoid clutter.
Pretty low tech in a way but it works.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.