Jump to content
Sign in to follow this  

Help with reading hardware and run script

Recommended Posts

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 &= "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
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" )
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))

Share this post

Link to post
Share on other sites

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
ElseIf StringInStr($Output, "Latitude") Then


Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...