Solved

Need wmic csproduct get name script for BIOS update, etc

Posted on 2010-09-09
3
1,406 Views
Last Modified: 2012-05-10
I'm needing some sort of script that I can run against 3 models of computers, and say "if wmic csproduct get name = 755 optiplex, run this......., and this. If wmic csproduct name = optiplex 620 run this, and this.
Basically just having to update bios and its settings, plug some power management settings on the NIC. I'm not the greatest scripter, but know what I'm needing. Any help is appreciated!
0
Comment
Question by:khptech
3 Comments
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 33636456
@echo off

wmic csproduct get name >#

findstr /i "755 optiplex" "#"

if %errorlevel%==1 goto install1

findstr /i "optiplex 620" "#"

if %errorlevel%==1 goto install2

:install1

run_file1.exe
goto end_script

:install2

run_file2.exe
goto end_script

:end_script
0
 
LVL 5

Expert Comment

by:MaxSoullard
ID: 33636480
Let me know if I am wrong, but I think you are trying to get the computer model. If this is the case this is a vb script that does that.

You will then need to adapt your if statments to match the correct names provided by the computer manufacturer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings 
    Wscript.Echo  objComputer.Model
Next

Open in new window

0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 33636705
Here's how I would approach it in a BAT file.  It uses WMIC to get the product name, and then based on that value can perform any needed logic.

~bp
@echo off
for /F "skip=2 tokens=2 delims=," %%A in ('wmic csproduct get name^,version /format:csv') do (
  if /I "%%A" EQU "755 optiplex" (
    REM insert processing needed here
    exit /b
  )
  if /I "%%A" EQU "optiplex 620" (
    REM insert processing needed here
    exit /b
  )
)

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now