WMIC Query to variable. 99% complete

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
flutters
Posts: 1
Joined: 12 Nov 2015 15:10

WMIC Query to variable. 99% complete

#1 Post by flutters » 12 Nov 2015 15:14

The end goal here is to make a login script that calls a program only if outlook is installed on a computer.

Thus far, I have this

Code: Select all

FOR /F "skip=1 tokens=* delims==" %%A IN ('WMIC /NameSpace:"\\root\WMI" product where "Name like '%%Outlook%%'" get Name') DO set "myVar=%%A"
ECHO %myVar%


This works, if you have echo on, you will see it pull the name of whatever flavor of outlook you currently have. However immediately after this, you can see it setting the Var to blank.

Is there some way to make this script stop after finding any value? Or am I missing something obvious that causes it to wipe my variable.

Thanks in advance for any help that can be provided.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: WMIC Query to variable. 99% complete

#2 Post by Compo » 13 Nov 2015 13:22

WMIC Output is notoriously bad to capture and whilst there are methods of fixing the output, why not just change to a registry check?

Code: Select all

Reg Query HKCR\Outlook.Application >Nul 2>&1 && <code to run program>

Post Reply