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
shyam pothiniAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Why not do this with a GPO and WMI filtering?
1
Darrell PorterEnterprise Business Process ArchitectCommented:
Batch file:
@for /f "tokens=*" %%m in ('wmic computersystem get model /value ^| find "="') do set %%m
@echo %Model%

Open in new window

0
Darrell PorterEnterprise Business Process ArchitectCommented:
To provide a more complete answer...

@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
Start /wait "Installer for 840G3.EXE"

Goto END

:840G4
Start /wait "Installer for 840G4.EXE" /Some_Parameter

Goto END

:850G4
Start /wait "Installer for 8%0G4.EXE"

Goto END

:END

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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

shyam pothiniAuthor Commented:
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.
0
Lee W, MVPTechnology and Business Process AdvisorCommented:
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?
0
shyam pothiniAuthor Commented:
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
0
Darrell PorterEnterprise Business Process ArchitectCommented:
You have to ensure the values Model is being set to match the comparison values in the script.
0
shyam pothiniAuthor Commented:
I ran query on each Pc and took the name from there, but I am not successful running this
0
shyam pothiniAuthor Commented:
Capture.PNG
its not recognizing then, Please see attached
0
Darrell PorterEnterprise Business Process ArchitectCommented:
Apologies

Change 'then goto' to just 'goto'
0
Darrell PorterEnterprise Business Process ArchitectCommented:
Have you tried making this change to the script yet?
0
Mladen CvijanovicSystems AdministratorCommented:
Shyam, what kind of the deployment agent do you have?
0
Darrell PorterEnterprise Business Process ArchitectCommented:
The author has not responded.  I proposed best solution and assisted solutions above.
0
shyam pothiniAuthor Commented:
thanks
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.