Return Machine Model 2 Ways

This will return the model of a computer. I am using this in conjunction with a computer naming script to name a computer using this convention: model-service tag

On error resume next

‘PRIMARY MODEL DETECTION
Set objWMI = GetObject(“winmgmts:”)
Set colSettings = objWMI.ExecQuery(“Select * from Win32_ComputerSystem”)

For Each objComputer in colSettings
LaptopModel = Trim(objComputer.Model)
Next

Select Case LaptopModel

Case “HP EliteBook 8470p”
‘strModel = “8470”

Case “HP EliteBook 8460p”
strModel = “8460”

Case “HP EliteBook 8450p”
strModel = “8450”

Case “HP EliteBook 8440p”
strModel = “8440”

Case “HP EliteBook 6930p”
strModel = “6930”

Case “HP EliteBook 2530p”
strModel = “2530”

Case “HP EliteBook 2540p”
strModel = “2540”

Case “HP Compaq dc7900 Small Form Factor”
strModel = “7900”

Case “HP Compaq 8000 Elite SFF PC”
strModel = “8000”

Case “HP Compaq 8200 Elite SFF PC”
strModel = “8200”

Case “OptiPlex 755”
strModel = “755”

Case “OptiPlex 745”
strModel = “745”

Case “Latitude D630”
strModel = “630”

Case “Latitude D620”
strModel = “620”

Case “Latitude D430”
strModel = “430”

End Select

‘SECONDARY MODEL DETECTION
if strModel = “” then
‘msgbox “no model was detected”
myLength = Len(LaptopModel)

For i = 1 To myLength
If Asc(Mid(LaptopModel, i, 1)) <> 32 Then
If Asc(Mid(LaptopModel, i, 1)) >= 48 And Asc(Mid(LaptopModel, i, 1)) <= 57 Then
myNumber = myNumber & Mid(LaptopModel, i, 1)
End If
Else
‘msgbox(“no numeric”)
End If
Next
‘msgbox(myNumber)
strModel = myNumber
end if

msgbox strModel

email me