View unanswered posts | View active topics It is currently 02 Oct 2014 08:28



Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Pulling the manufacturer from computer 
Author Message

Joined: 10 Jul 2012 13:47
Posts: 38
Post Re: Pulling the manufacturer from computer
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


11 Jul 2012 10:03
Profile

Joined: 10 Feb 2012 02:20
Posts: 4241
Post Re: Pulling the manufacturer from computer
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"


11 Jul 2012 10:30
Profile

Joined: 10 Feb 2012 02:20
Posts: 4241
Post Re: Pulling the manufacturer from computer
And this will work to find dell in any machine vendor string

Code:
@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
)



11 Jul 2012 10:35
Profile

Joined: 10 Jul 2012 13:47
Posts: 38
Post Re: Pulling the manufacturer from computer
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


11 Jul 2012 10:40
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2


Who is online

Users browsing this forum: Bing [Bot], darioit, Google [Bot] and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.