Page 2 of 2

Re: Pulling the manufacturer from computer

Posted: 11 Jul 2012 10:03
by gymiv
this will work
@echo off
cls
For /F "skip=1 tokens=1" %%A IN ('WMIC csproduct get vendor') DO echo %%A
pause

but it will not work with the set statement so i can use the if statement

Re: Pulling the manufacturer from computer

Posted: 11 Jul 2012 10:30
by foxidrive
In Win7 there is a trailing crlf that wipes the machine variable.

This should work in all OS

for /f "skip=1 delims=" %%a in ('WMIC csproduct get vendor') do if not defined machine set "machine=%%a"

Re: Pulling the manufacturer from computer

Posted: 11 Jul 2012 10:35
by foxidrive
And this will work to find dell in any machine vendor string

Code: Select all

@echo off
set "machine="
for /f "delims=" %%a in ('WMIC csproduct get vendor ^|find /i "dell" ') set "machine=%%a"

If defined machine (
echo it's a Dell "%machine%"
) else (
echo it wasn't a Dell
)


Re: Pulling the manufacturer from computer

Posted: 11 Jul 2012 10:40
by gymiv
That seems to have worked. Thanks again everyone. Nice to simplify the batch. Here is final code and results.

REM @ECHO OFF
for /f "skip=1 tokens=1" %%a in ('WMIC csproduct get vendor') do if not defined machine set "machine=%%a"
ECHO Computer model: "%machine%"

IF %machine%==Dell (
GOTO :setup
) ELSE (
GOTO :end
)


:setup
echo success
pause > nul
GOTO :eof


:end
echo not yet
pause > nul
GOTO :eof

C:\Users\JimT\Desktop>REM @ECHO OFF

C:\Users\JimT\Desktop>for /F "skip=1 tokens=1" %a in ('WMIC csproduct get vendor
') do if not defined machine set "machine=%a"

C:\Users\JimT\Desktop>if not defined machine set "machine=Dell"

" \Users\JimT\Desktop>if not defined machine set "machine=

C:\Users\JimT\Desktop>ECHO Computer model: "Dell"
Computer model: "Dell"

C:\Users\JimT\Desktop>IF Dell == Dell (GOTO :setup ) ELSE (GOTO :end )

C:\Users\JimT\Desktop>echo success
success

C:\Users\JimT\Desktop>pause 1>nul