where am I going wrong with this batch...

February 24, 2010 at 15:56:01
Specs: Windows XP
Where am I going wrong with this batch file?

All seems well but when the results are presented, I have more that I want.

@echo off

cls

wmic /output:%temp%\InstallList.txt product get name,version

find "HP Wireless" %TEMP%\InstallList.txt

FOR /F "tokens=1 usebackq delims=. " %%i IN (%TEMP%\InstallList.txt) DO set %%i


What I WANT it to output is JUST the version (3.0.11.2) from the line below.

--example of the line I'm looking for from the text file--
HP Wireless Assistant 3.0.11.2


What it IS putting out is:

---------- C:\DOCUME~1\MYPCNAME\LOCALS~1\TEMP\INSTALLLIST.TXT
HP Wireless Assistant 3.0.11.2


Can anyone point me in the right direction?


See More: where am I going wrong with this batch...

Report •

#1
February 24, 2010 at 18:00:36
"find" puts filename stuff unless you pipe into it:

for /f "tokens=*" %%a in ('find "HP Wireless"^<%TEMP%\InstallList.txt') do echo %%a




Report •

#2
February 24, 2010 at 21:10:29
How 'bout:

tokens=4


=====================================
Helping others achieve escape felicity

M2


Report •

#3
February 25, 2010 at 04:05:51
Hmm, that would work in THIS case, but I don't like these kind of hardcoded find commands, since you are browsing throug text, which can be changed easily. Example, next version may be :

Hewlett Packard Wireless Assistant 5.8.2
or
HP <name_of_company_buying_HP> Wireless Assistent Component Version 8.0

An idea would be to to only take numbers (and digits) out of the whole line, but that is not much better.


Report •

Related Solutions

#4
February 26, 2010 at 08:21:01
Awesome! Thanks all!!

Ended up with:

@echo off

cls

wmic /output:%temp%\InstallList.txt product get name,version

for /f "tokens=6" %%a in ('find "HP Wireless"^<%TEMP%\InstallList.txt') do echo %%a


Which results in...

3.0.11.2


PERFECT!!!


Report •

#5
February 26, 2010 at 09:12:17
It does for this specific line, indeed

Report •

Ask Question