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
Pulling the manufacturer from computer
Moderator: DosItHelp
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"
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
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
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
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