Link to home
Start Free TrialLog in
Avatar of shyam pothini
shyam pothini

asked on

Create a script to install application

Hello all,

we have 3 different hardware models running windows 7. we want to deploy a application based on the model. How can I create a batch file o any other script to run "wmic computersystem get model" based on the model go to model folder and install that application.
For example,
hardware models
HP EliteBook 840 G3
HP EliteBook 840 G4
HP EliteBook 850 G4

There is folder on server share having folder matching same name.

if script detects "HP EliteBook 840 G3", it should check that folder and match the folder name and install the application insid it.

Is there any way to do that?

Regards
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Why not do this with a GPO and WMI filtering?
Batch file:
@for /f "tokens=*" %%m in ('wmic computersystem get model /value ^| find "="') do set %%m
@echo %Model%

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Darrell Porter
Darrell Porter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shyam pothini
shyam pothini

ASKER

Thanks for the comments,
@Lee we have deployment agent, so we want to use script, But I will talk to my Boss.
@Darrel, I will try this.
You can hammer a nail with a screwdriver because you have it... or you can use a hammer - because you have it.  Which tool should you use?  The one that will work or the one that will work well?
Lee, I like to use AD, but its not me making decisions, anyways I am proposing it to my superiors.

@Darell,
I changed the script to test as follows and it didn't work, am I doing anything wrong
@for /f "tokens=*" %%m in ('wmic computersystem get model /value ^| find "="') do set %%m
@echo %Model%

If "%Model%" == "HP EliteBook 840 G3" then Goto 840G3
If "%Model%" == "HP EliteBook 840 G4" then Goto 840G4
If "%Model%" == "HP EliteBook 850 G4" then Goto 850G4
Goto WrongModel

:840G3
ping google.com

Goto END

:840G4
ping yahoo.com

Goto END

:850G4
timeout /t 100

Goto END

:END
You have to ensure the values Model is being set to match the comparison values in the script.
I ran query on each Pc and took the name from there, but I am not successful running this
User generated image
its not recognizing then, Please see attached
Apologies

Change 'then goto' to just 'goto'
Have you tried making this change to the script yet?
Shyam, what kind of the deployment agent do you have?
The author has not responded.  I proposed best solution and assisted solutions above.
thanks