googlemad Posted March 20, 2019 Posted March 20, 2019 On our machines we have Software ABC v1.0, installed under c:\program files\abc Now the supplier has sent us an updated v1.2 version to deploy They have supplied the v1.2 MSI and I have placed this in a simple batch file to run at shutdown / restart via Group Policy This works great with 'if exist' statements (e.g. if exist c:\program files\abc\abc.exe then continue to the update step of the batch file, if not just exit out) The issue is this would then run at every shutdown / restart, but it only needs to be run once if the older version is installed (in fact updating more than once is a big problem as it resets a connection string file each time!) Now if I look at the file properties of abc.exe in Windows it helpfully reports a version number, so what is the easiest way to extend my batch file to detect this version number? Also I have another issue in it has a different installer for 32bit/64bit so if I could also extend my batch file to detect platform that would be great although I have other ideas on how to get around that!
Steve21 Posted March 20, 2019 Posted March 20, 2019 To be honest unless you really want to check version number you could just do a file check and write like a “updated.txt” into said location Again unless you really want to get into os versions just check if x86 programs exist as it’ll be 64 then etc If you want it to check let me know as I have an old script that did it somewhere but stopped using it as going the above easier to use on multiple programs and os versions etc Steve 1
googlemad Posted March 25, 2019 Author Posted March 25, 2019 In the end I used GPP to create a text file based on EXE version number conditions, and another condition to create a slightly differently named text file if x64 ('if c:\program files (x86) exists') I then fed the text file names into the batch file and all working well, once the new version is installed a seperate GPP entry then in place to remove the text file again based on EXE version number Pity there isn't group policy conditions for startup/shutdown scripts to begin with as that would make it even easier!
FishCustard Posted March 25, 2019 Posted March 25, 2019 You can pull the version of a file with PowerShell, if that helps. https://blogs.technet.microsoft.com/askpfeplat/2014/12/07/how-to-correctly-check-file-versions-with-powershell/ 1
Arthur Posted March 26, 2019 Posted March 26, 2019 You can pull the version of a file with PowerShell I was going to suggest the same thing. Personally I would have done the whole script in PowerShell. It's much easier to do most things compared to batch files. 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now