Batch file advice for detecting hardware

We use a batch file to execute a variety of repetitive commands on newly-built computers. There are two points in this batch file where WMI commands are used to (1) detect the presence of a specific SSD manufacturer and (2) detect the model name of the computer. I found the WMI commands that would display the needed output, but I think the approach could use some review.

The detection of the model goes works fine:

FOR /F "tokens=2 delims==" %%A IN ('WMIC csproduct GET Name /VALUE ^| FIND /I "Name="') DO SET machine=%%A
FOR /F "tokens=1 delims= " %%A IN ('echo %machine%') DO SET machine=%%A
ECHO Computer model: %machine%
SET machine2=%machine: =%
ECHO Configuring settings and installing applications per platform type...
IF /I "%machine2%" == "Latitude" GOTO NOTEBOOK
IF /I "%machine2%" == "Precision" GOTO WORKSTATION
IF /I "%machine2%" == "Optiplex" GOTO DESKTOP

Open in new window


PROBLEM AREA:

I tried using the same approach to detect if a computer had an Intel SSD installed using this:

FOR /F "tokens=2 delims==" %%A IN ('WMIC diskdrive get model /value ^| FIND /I "Model="') DO SET model=%%A
FOR /F "tokens=1 delims= " %%A IN ('echo %model%') DO SET model=%%A
ECHO SSD Manufacturer: %model%
SET model2=%model: =%
IF /I "%model2%" == "INTEL" GOTO INTELSSD

Open in new window


Even if the computer has a non-Intel SSD it still will proceed to the designated step of installing the Intel SSD Toolbox.

Is there a better way to structure this so I do not have to list every that might be detected so that it will skip the installation of the Intel SSD Toolbox?
hufftwAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
You can just skip the toolbox installation if the manufacturer is not Intel (and shorten the code):
FOR /F "tokens=2 delims== " %%A IN ('WMIC diskdrive get model /value ^| FIND /I "Model="') DO SET model=%%A
ECHO SSD Manufacturer: '%model%'
if /i not "%model%" == "INTEL" GOTO EndIntelSSDToolbox
setup.exe ...
:EndIntelSSDToolbox

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oBdACommented:
As far as the first part is concerned, you could do it like that, including a check for unsupported hardware, just in case:
FOR /F "tokens=2 delims== " %%A IN ('WMIC csproduct GET Name /VALUE ^| FIND /I "Name="') DO SET machine=%%A
ECHO Computer model: '%machine%'
ECHO Configuring settings and installing applications per platform type...
IF /I "%machine%" == "Precision" GOTO WORKSTATION
IF /I "%machine%" == "Optiplex"  GOTO DESKTOP
IF /I "%machine%" == "Latitude"  GOTO NOTEBOOK
echo Unknown machine '%machine%' found!
goto :eof
:WORKSTATION
...
goto EndPlatform
:DESKTOP
...
goto EndPlatform
:NOTEBOOK
...
goto EndPlatform
:EndPlatform

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.