File Copy/Terminate/Rename Routine
Hi All,
Had a request from one of my customers today, and used PDQ to resolve this situation for us. Quite pleased with the result and thought I would share the code.
Request : Check if the program is running on the computer, if so terminate it, check the file version of file x, and rename the file to x-1.2.3.4, then copy over newer version. The renaming of the old file, would allow us to roll back if required.
XML code can be found here XML Export, In the properties details of the package I have provided step by step instructions of how to use the package, but for ease of use I have provided them below as well.
- Import .XML file into PDQ
- In the properties of the program, and if required specify the condition for the filename and version
- In Step 1 - "Terminate and process...." edit this and ensure that you amend the $Program variable to your exact program name
- In Step 2 - "Rename Existing File........" edit this and ensure that you amend the $filelocation and $filename variables
- In Step 3 - "File Copy..............................." ensure that you change the source and destination target sub-directory accordingly
I added a little more functionality in Step 1, as you may want to end the package if the user is actually running the software, so you can specify the $KillProcess variable to True or False to accommodate.
Anyway, happy to share and happy for comments, suggestions and amendments.
Comments