Jump to content

wmic query


Recommended Posts

i'm trying to query my computer with multiple ... "searches"?

my first line is working,

wmic product where "name like 'java%'" get description

i also want to run this at the same time

wmic os get csname

so basically when i run the code, i'll get the computer name and java version at the same time, (it doesn't need to be formatted like that, but something close)

once i get it working, i can use the /node and run this against my entire network

CSName      Description
PC1             Java8 Update 111

any clues?

Link to comment
Share on other sites


I don't understand.

Make a batch, get the CSName first, then get the Java version (or viceversa), then output these two pieces of info together.

However you will need some further "filtering" of the results, running "wmic product where "name like 'java%'" get description" produces:

Description
Java(TM) 6 Update 24
Java 8 Update 66
Java Auto Updater

on my machine.

The "base" should be more or less:
 

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
FOR /F "USEBACKQ TOKENS=*" %%A IN (`WMIC PRODUCT WHERE "name like 'java%%'" GET DESCRIPTION /format:list^|FIND "="`) DO ECHO my%%A 
FOR /F "TOKENS=*" %%A IN ('WMIC OS GET CSNAME /format:list^|FIND "="') DO ECHO my%%A

FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%A IN (`WMIC PRODUCT WHERE "name like 'java%%'" GET DESCRIPTION /format:list^|FIND "="`) DO CALL :Print_and_set myJava "%%A"
FOR /F "TOKENS=2 DELIMS==" %%A IN ('WMIC OS GET CSNAME /format:list^|FIND "="') DO CALL :Print_and_set myCS "%%A"
ECHO.
SET my

GOTO :EOF

:Print_and_set
ECHO %1 is %2
SET %1=%2

(for some strange reason - at least on my machine - there is a display glitch and the "m" in my%%A for the description is omitted, so I used the CALL)

jaclaz 
 

Link to comment
Share on other sites

Yes :), but you create a (temporary) file that - before or later - you will need to parse in order to use the information in it.

The output of that on my machine:
 

Quote


Node,Description
CINQUE,Java(TM) 6 Update 24
CINQUE,Java 8 Update 66
CINQUE,Java Auto Updater

jaclaz
 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...