Hello,
I am trying to figure out how to run a command which will do a silent upgrade of VMWare Tools if and only if the version of VMWare Tools that is already installed is older than the one that it is being upgraded to.
I basically figured I could do the silent upgrade if the VMWare Tools was different from the one that is going to be installed but I am having problems figuring out how to do that. What follows is my sort of pseudocode
for doing this:
*******************************************************************************************************************************
BuildVersion=8.8.2.10499 (build-590212)
If C:\Program Files\VMWare\VMWare Tools\VMwareToolboxCmd.exe -v "DIFFERENT TO" BuildVersion
then
\\NETWORK_SHARE\install\packages\VMware\vmtoolsupdate\setup.exe /S /v"/qn
else
exit
*******************************************************************************************************************************
So basically I have a variable called BuildVersion and if running VMwareToolboxCmd.exe -v (this command gives the build version of the VMware Tools already installed on the host) is different to the BuildVersion variable then run setup.exe with /S /v"/qn switches which is located on a network share ELSE exit. But it is not working and I can't figure out how to do the "DIFFERENT TO" bit. I am a scripting newbie and I have looked online without much avail so any help would be much appreciated. I hope this is the right forum for asking such basic questions.
Thank you,
Tahir
How to test for difference in output and then execute
Moderator: DosItHelp
Re: How to test for difference in output and then execute
Where are you getting the latest build version from?
See what this generates. The details of the comparison commands depend on what output the vmware tool spits out.
The comparison command requires that you have two build numbers in the same format and you would use this:
See what this generates. The details of the comparison commands depend on what output the vmware tool spits out.
Code: Select all
@echo off
for /f "delims=" %%a in ('
"C:\Program Files\VMWare\VMWare Tools\VMwareToolboxCmd.exe" -v
') do echo "%%a"
The comparison command requires that you have two build numbers in the same format and you would use this:
Code: Select all
if not "%buildold%"=="%buildnew%" "\\NETWORK_SHARE\install\packages\VMware\vmtoolsupdate\setup.exe" /S /v /qn
Re: How to test for difference in output and then execute
Okay thanks foxidrive I get some output for that FOR loop:
"8.8.2.10499 (build-590212)"
But I can't figure out how to SET that FOR loop output as the 'buildold' variable?
I mean if I could set 'buildold' as a variable then I could compare it to the 'buildnew' variable.
Thanks
"8.8.2.10499 (build-590212)"
But I can't figure out how to SET that FOR loop output as the 'buildold' variable?
I mean if I could set 'buildold' as a variable then I could compare it to the 'buildnew' variable.
Thanks
Re: How to test for difference in output and then execute
tomhafiz wrote:Okay thanks foxidrive I get some output for that FOR loop:
"8.8.2.10499 (build-590212)"
Ok, so now you have the buildold variable.
Same code, just set the output to a variable name.
Code: Select all
@echo off
for /f "delims=" %%a in ('
"C:\Program Files\VMWare\VMWare Tools\VMwareToolboxCmd.exe" -v
') do set "buildold=%%a"
echo old build revision is "%buildold%"
What I don't know is how you are going to get the new build information, with batch code.
If it is on a web page then you can download the web page with the free wget.exe tool and then parse the HTML and extract the new build code - but we'd have to see the web page to see what format it is in.
Re: How to test for difference in output and then execute
Foxidrive, actually I already have the current build code and current VMwareTools etc. This exercise is to update any old builds of VMwareTools on workstations and I have tested the code and it works:
@echo off
set buildnew=8.8.2.10499 (build-590212)
echo new build version is "%buildnew%"
for /f "delims=" %%a in ('
"C:\Program Files\VMWare\VMWare Tools\VMwareToolboxCmd.exe" -v
') do set "buildold=%%a"
echo installed build version is "%buildold%"
if not "%buildold%"=="%buildnew%" "\\NETWORK_SHARE\install\packages\VMware\vmtoolsupdate\setup.exe" /S /v /qn
So now this code can be put into a Group Policy Object and pushed out to all the workstations on the domain and if the VMwareTools is out of date compared to the current one it will do a silent install from the network share.
Thanks very much for all your help.
@echo off
set buildnew=8.8.2.10499 (build-590212)
echo new build version is "%buildnew%"
for /f "delims=" %%a in ('
"C:\Program Files\VMWare\VMWare Tools\VMwareToolboxCmd.exe" -v
') do set "buildold=%%a"
echo installed build version is "%buildold%"
if not "%buildold%"=="%buildnew%" "\\NETWORK_SHARE\install\packages\VMware\vmtoolsupdate\setup.exe" /S /v /qn
So now this code can be put into a Group Policy Object and pushed out to all the workstations on the domain and if the VMwareTools is out of date compared to the current one it will do a silent install from the network share.
Thanks very much for all your help.