Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Batch file with computer@prod_name

Created: 09 Oct 2012 • Updated: 10 Oct 2012 | 10 comments
This issue has been solved. See solution.

Hi I am trying to create a batch file to pick a computers model and then install extra apps according to the model number, these are mostly drivers that do not install during our driver inject in winpe ie webcam, OSD drivers 9010 Allinone etc.

Unfortunately the script ignores (or doesn't) do the goto, no errors, but tries to install the software for each model.

if "%#!computer@prod_name%" == "Optiplex 9010" goto 9010
if "%#!computer@prod_name%" == "Latitude 6530" goto 6530
if "%#!computer@prod_name%" == "Latitude 5430" goto 5430
if "%#!computer@prod_name%" == "Latitude 5430 non-vpro" goto 5430-nonvpro

:9010
rem 9010 - install dell webcam
c:\drivers\webcam\setup.exe -s setup.iss

Etc etc.....

I can send a script as below to a computer and it will respond with the correct computer product name

echo %#!computer@prod_name%
pause

Any ideas?

Thanks, Cat

Comments 10 CommentsJump to latest comment

BBC's picture

Hi Cat,

I would start by adding some logging into the script so that you know at what stage you lose information, like below. Besides, I believe the issue is that you run the script on the client and at the same time run a call against the DB, which may not work as the client does not access the DB, but the DS does.

-BBC

SET prod=%#!computer@prod_name%
if "%#!computer@prod_name%" == "Optiplex 9010" goto 9010
if "%#!computer@prod_name%" == "Latitude 6530" goto 6530
if "%#!computer@prod_name%" == "Latitude 5430" goto 5430
if "%#!computer@prod_name%" == "Latitude 5430 non-vpro" goto 5430-nonvpro

:9010
\\%DSSERVER%\eXpress\wLogEvent -c:0 -l:2 -ss:" %prod% identified."
some script here

GOTO END

:6530
\\%DSSERVER%\eXpress\wLogEvent -c:0 -l:2 -ss:" %prod% identified."
some script here

GOTO END

And so on and so on...

Guido Langendorff's picture

Should it not be like this?

SET prod=%#!computer@prod_name%
if "%prod%" == "Optiplex 9010" goto 9010
if "%prod%" == "Latitude 6530" goto 6530
if "%prod%" == "Latitude 5430" goto 5430
if "%prod%" == "Latitude 5430 non-vpro" goto 5430-nonvpro

andykn101's picture

Looks like the sytax is OK, very similar to mine except I use model_num.

BBC's suggestion is excellent, I'd just be lazy and stick a pause in after the If... lines to see what's going on and watch it in automation.

Authorised Symantec Consultant (ASC) with Endpoint Management Limited, an Authorised Symantec Delivery Provider based in the UK.

Connect Etiquette: Please "Mark as Solution" posts that fix your problem.

BBC's picture

Hi Guido,

Thanks for the hint, yes, nearly what it is supposed to look like.

Shoudl look like:

SET prod=%#!computer@prod_name%

IF %prod%=="blabla" GOTO ... etc.

Note the % around the variable, which make sure the variable is recognized as such.

bhawver's picture

A script like that could get pretty bloated over time as you add more and more models.  Seeing as you are using DS 6.9, you might consider using conditions in your jobs.

Brian Hawver
Systems Engineer
Yaskawa America, Inc.

Connect Etiquette: "Mark as Solution" those posts which resolve your problem, and give a thumbs up to useful comments, articles and downloads.

dsmith1954's picture

Conditions are what we use. Much easier, and you don't have to rely on the client accessing the db. The job does it for you.

cathossie's picture

Big thanks to all who replied, all information was very useful, and the quick responses were appreciated.

My final script is below and as Guido suggested.

I did have issues with case sensitivity ie: the result of  "prod" must exactly match ie: Optiplex 9010 will not work needs the capital P "OptiPlex". I have also found that the case capitols can change between windows xp and windows 7, but as we are moving to Windows 7 I am not worrying about the windows xp installs.

The only thing I would like to do now is distinguish between a 9010 desktop and a 9010 All in one. They both have the same prod_name, and I've found in the past with Dell computers the model_num can vary between delivery batches!!!

-------------------------------

SET prod=%#!computer@prod_name%

if "%prod%"=="OptiPlex 9010" goto 9010
if "%prod%"=="Latitude E6510" goto 6510
if "%prod%"=="Latitude E6520" goto 6520
if "%prod%"=="Latitude E6530" goto 6530
if "%prod%"=="Latitude E5430" goto 5430
if "%prod%"=="Latitude E5430 non-vPro" goto 5430-nonvpro

goto end

:9010
rem Installing Drivers for Optiplex 9010
rem 9010 install dell webcam
c:\drivers\webcam\setup.exe -s setup.iss
Rem 9010 Install OSD Drivers for All In ONe
c:\drivers\allinone\osd\setup.exe -s setup.iss
goto end

:6510
rem Installing Drivers for Latitude E6130
rem E6510 install dell webcam
c:\drivers\webcam\setup.exe -s setup.iss
goto end

SOLUTION
andykn101's picture

Add:

SET model=%#!computer@model_num%

And use a combination of the the two where necessary.

Authorised Symantec Consultant (ASC) with Endpoint Management Limited, an Authorised Symantec Delivery Provider based in the UK.

Connect Etiquette: Please "Mark as Solution" posts that fix your problem.

BBC's picture

I have moved away from that - at least when it comes to Win7 deployment. I use a VBS running a WMI and determining the product name (i.e. Dell OptiPlex XE, HP Elite dc8300 SFF) and so simplify the whole thing for our environment.

With that, I do not have any dependency on how to get appropriate driver or software packages down to a specific client.

Cat,

Just a suggestion, but if you have to update certain packages, you will go thru the entire event and update whatever path and command lines you have? Why not use a script file (VBS/CMD/PS1) along with the packages and use that locally on the client machine to perform tasks you have to? You have less overhead when it comes to maintaining such tasks and you're always specific to a model/product.

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct",,48)

cathossie's picture

Hi BBC I'd be more than happy on trying your suggestion, if you have an example script would be a great on how the install happens etc.I am still teaching myself to write code, I am really keen to get powerscript examples as I see that being the way forward. But VBS is still good.

I am using DS6.9 and NS7.1 and could user either for what I want to do.

When we had NS6.5 I used to create a package for a specific driver then use a query on the collection for the models that required the driver. 

Example Below:

Filters by:

Inv_aex_hwSerial_number - computer model = Latitude E6520

Inv_AeX_OS_Operating_System - OS name= Windows 7

Inv_Aex_Operating_Architecture=64

The trouble is I cannot convert this in NS7.1 the sql code from ns6.5 does not work in NS7.1 and I am really finding the query builder in NS7.1 difficult to get correct!!!