S1LV3RF1$# Posted January 31, 2006 Posted January 31, 2006 Ok so here is the deal I am trying to create a script that after you install Windows it will kick off a VB Script that will poll WMI for the Model of the Machine that you just Installed Windows on (Done with a Runeonce command). Now when the script figures out what it is(Ex. Gx240) then i want it to install The software that was packaged with that specific model (Ex. DVD Sofware, Cd Burning software) and the Drivers for the specific Model. I know that this can be done with "If Then" statements. I was just woundering if this can be accomplished with Less Code then a ton of If then Statements.I will be using this for Dell GX240, 260, 270, 280, 620's and also for HP DC 5000'sAnd eventually for Laptops as well.
RogueSpear Posted February 2, 2006 Posted February 2, 2006 I posted a VBscript that determines chasis type and installs the Cisco VPN Client only if it's a "portable" computer. You can find it in my guide to RIS (link in my sig). It uses a Case/Select structure, which is probably what would be appropriate for what you want to do.
gunsmokingman Posted February 2, 2006 Posted February 2, 2006 Try this VBS script it should help. Save As ListCpuProperties.vbsstrComputer = "." : Dim Act, CName, FName, Fso, Ln1, SD, S_5, TsSet Act = CreateObject("Wscript.Shell") : Set Fso = CreateObject("Scripting.FileSystemObject")SD = Act.ExpandEnvironmentStrings("%SystemDrive%") : CName = Act.ExpandEnvironmentStrings("%ComputerName%")FName = (SD & "\" & CName & ".txt") : S_5 = Space(5): Ln1 = Chr(171) & " --------------- " & Chr(187) Set Ts = Fso.CreateTextFile(FName) Ts.WriteLine S_5 & Now() & Ln1 & Act.ExpandEnvironmentStrings("%UserName%") Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48) Set objItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS") Set CpuInfo = objWMIService.ExecQuery("SELECT * FROM Win32_Processor") For Each objItem in colItems Ts.WriteLine S_5 & "Computer Name : " & UCase(objItem.Caption) Ts.WriteLine S_5 & "Description : " & UCase(objItem.Description) Ts.WriteLine S_5 & "Manufacturer : " & UCase(objItem.Manufacturer) Ts.WriteLine S_5 & "Model : " & UCase(objItem.Model) Ts.WriteLine S_5 & "Number Of CPU`s : " & UCase(objItem.NumberOfProcessors) Ts.WriteLine S_5 & "SystemType : " & UCase(objItem.SystemType) For Each strItem in objItems Ts.WriteLine S_5 & "Processor : " & UCase(strItem.Version) Next For Each strCpu in CpuInfo Ts.WriteLine S_5 & "Cpu Details : " & UCase(strCpu.Description) Next Next Ts.WriteLine S_5 & Ln1 : Ts.Close : Act.Run(FName)
S1LV3RF1$# Posted March 28, 2006 Author Posted March 28, 2006 Thanks to all this is what i came up with from Suggestions and a little surfin'on error resume nextDim strComputer, objWMIService, strmodel, colmodel, objitem strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colmodel = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") 'Install Model Specfic software / Drivers For Each objitem in colmodel wscript.echo objitem.model Select Case trim(objitem.model) Case "Optiplex GX620" wscript.echo "You are on a Dell 620" 'Install stuff Case "Evo N400c" wscript.echo "You are on a Compaq N400c" Case "Evo N800c" wscript.echo "you are on a Compaq N800c" Case "HP Compaq nc8000 (DH918U#ABA)" wscript.echo "you are on a HP NC8000" Case "HP dc5000 uT (PS666UC)" wscript.echo "you are on a HP DC5000" Case "ClientPro CR" wscript.echo "You are on a Micron" Case "OptiPlex GX240" wscript.echo "You are on a Dell GX240" Case "OptiPlex GX260" wscript.echo "You are on a Dell GX260" Case "OptiPlex GX270" wscript.echo "You are on a Dell GX270" Case "OptiPlex GX280" wscript.echo "You are on a Dell GX280" Case "Latitude X1" wscript.echo "you are on a dell X1" Case "Latitude D610" wscript.echo "You are on a Dell 610" 'Install VPN Client and Configure it Case "Latitude D600" Wscript.echo "you are on a Dell 600" 'Install VPN Client and Configure it Case "Latitude D510" Wscript.echo "you are on a Dell 510" 'Install VPN Client and Configure it Case Else Wscript.echo "Computer Type Unknown" End SelectNext
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now