Jump to content

Simple computer Model Script


Recommended Posts

Hey guys,

trying to figure out why this script won't go through

Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim objComputer, strModel

For Each objComputer in colSettings
If objComputer.Model = "OptiPlex GX270" then
wscript.echo "test"
end if
strModel = objComputer.Model
Next
wscript.echo "Computer Model: " & strModel

shoudl just return the computer model and then have different actions based on what model it is

i tried a select case statement with no luck, it doesn't want to pickup the objComputer.Model value in the IF statement

Link to comment
Share on other sites


Try the script this way first to see what comes back this will give you what the correct needed for the bottom script.

Dim objWMI		  : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim objComputer, strModel

For Each objComputer in colSettings
wscript.echo objComputer.Model
Next

Then try the scrip this way with the correct string I left what the string that was return on my computer from the top script this script below did return the strModel varible

Dim objWMI		  : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim objComputer, strModel

For Each objComputer in colSettings
If objComputer.Model = "L7VMM3" then
strModel = objComputer.Model
end if
Next
wscript.echo "Computer Model: " & strModel

Link to comment
Share on other sites

Dim objWMI		  : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim objComputer, strModel

For Each objComputer in colSettings
wscript.echo objComputer.Model
If objComputer.Model = "OptiPlex GX270" then
strModel = objComputer.Model
end if
Next
wscript.echo "Computer Model: " & strModel

this is what i am working with, the value comes bac as "OptiPlex GX270" but when i use that vaule it fails, it is driving me insane, this should have been pretty simple.

Link to comment
Share on other sites

Try this script I change the querry to look for the manufacture

Dim objWMI		  : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim objComputer, strModel

For Each objComputer in colSettings
If objComputer.Manufacturer = "ECS" Then
strModel = "Computer MotherBoard : " & objComputer.Model & vbCrLf &_
"Computer Manufacturer : " & objComputer.Manufacturer
end if
Next
wscript.echo strModel

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...