All Forums >> [Scripting] >> WSH & Client Side VBScript >> Newbie Help (Basic decision making in script) Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Original message moved by dm_4ever Reason : Moving to Appropriate Forum Hi everyone, I am very new to scripting but its now a job requirement. I know the basics but need a little help. I am using Primalscript as my editor. I copy and paste most of the scripts from the help documents then edit as needed.
Here is what I need to do.
1. Detect the model of a computer 2. If the model matches a specific model then run an installation
Here is the script I am using to pick up the model number and it works just right:
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 "System Model: " & objComputer.Model Next
Here is my output:
System Model: OptiPlex 745 Exit code: 0 , 0000h
So it is working fine but now I need to add some logic to tell it "If the computer is an OptiPlex 745 then run a program. Also, the Exit code has me confused.
Here is some snippet of code I have been running to detect the model, it isn't completed, it is still in the testing phase, but it will give you an idea what to do:
The gx270 is a sub to detect the BIOS version and if it matches, then it won't install