prophet0621 Posted September 13, 2011 Share Posted September 13, 2011 I have a Windows image I've put together that runs on both laptops and desktops. The desktops need software removed, a few registry entries are deleted or changed and files removed so I put together a basic script to accomplish this. We also have some laptops that need things altered and have a second script. I would prefer to have one script that will read the model and if "OptiPlex 7xx"" to run the desktop, if "Latitude xxxx" run the laptop script. I used Scriptomatic for AutoIt to read the model (attached below) but not sure how to proceed from here. Can someone offer any pointers? Thank you! ; Generated by AutoIt Scriptomatic September 08, 2011 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $Output &= "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output &= "Model: " & $objItem.Model & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc Link to comment Share on other sites More sharing options...
AdamUL Posted September 13, 2011 Share Posted September 13, 2011 I would convert your two separate scripts to functions. Then use StringInString, to check for OptiPlex or Latitude for the the output. e.g.If StringInStr($Output, "OptiPlex 7") Then _OptiPlexFunc() ElseIf StringInStr($Output, "Latitude") Then _LatitudeFunc() Else EndIf Adam Link to comment Share on other sites More sharing options...
prophet0621 Posted September 13, 2011 Author Share Posted September 13, 2011 Thank you!! Works great in my quick test. I really appreciate the help. I'm still learning this and thanks to you I just learned StringInStr Link to comment Share on other sites More sharing options...
AdamUL Posted September 13, 2011 Share Posted September 13, 2011 Glad I could help. Adam Link to comment Share on other sites More sharing options...
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