WMIC if else commands

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

WMIC if else commands

Post by MigrationUser »

17 Oct 2013 11:48
diasje

Hello guys, i need to update iTunes in 800+ computers.

The version number is deployed thru a txt file:

I am trying to start a logon script where i query if itunes is updated, i am not used with wmic commands so i need something like:

Code: Select all

    if version is 11.1.1.11 (version.txt) goto end, else start itunesupdate.bat

This is the command to get the installed iTunes version

Code: Select all

    wmic product where name="iTunes" get name, version
Now i need something to query a txt file where the actual version number is

If version is diferent, then run the command:

Code: Select all

    \\10.x.xxx.xxx\hgw\sc\itunes_update.bat
----------------------------

#2 17 Oct 2013 16:01
foxidrive


This expects version.txt to contain a simple number like 11.5.3.0 and will compare the itunes version with it.

if the iTunes version is different or if iTunes is not installed then it will call the batch file.

Test it first.

Code: Select all

@echo off
set "newnum="
set /p "newnum=" <"version.txt"
for /f "tokens=2" %%a in ('
"wmic product where name="iTunes" get name, version |find "." "
') do if not "%newnum%"=="%%a" call "\\10.x.xxx.xxx\hgw\sc\itunes_update.bat"
pause
----------------------------

#3 17 Oct 2013 17:06
diasje


Very nice, i will test it with a few computers.

Thanks

----------------------------

#4 23 Oct 2013 16:03
diasje


Tested and worked very well
Post Reply