Sign in to follow this  
Followers 0
laidback01

PC Build Verification sheet

2 posts in this topic

#1 ·  Posted (edited)

So, this is no where near complete, but the code portion below does work. this will eventually be a quick click & look to see if everything is installed and running as expected.

Anyway, i'm looking for input, known better ways to do it, etc. I'm just learning this and VB is rather new to me in general and as such so is AutoIT!

thanks for taking the time, and Merry Christmas!

#cs ##########
VERIFICATION SYSTEM TO CHECK FOR CORRECT BUILD OF PC

The purpose of this script is first and foremost to be part of a larger project  aimed at making the building and installation of PCs easier.  
However, this script is currently separate and as such, its only purpose is to validate the readiness of a PC for installation out in the field.

 Need to find out several things:
 1) Windows Firewall Status
 2) Which Updates Installed
 3) Service Pack Level
 4) Which Software Installed
 5) Domain that LocalHost is part of
 6) IP of nic
 7) DNS setup

#ce ##########

#include <Constants.au3>
#include <Array.au3>
Dim $serviceArray[1][1]
Dim $serviceState, $serviceName


; Keep to single instance
$g_szVersion = "Sniper 1.1"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)
; Run with Admin Rights only.
#RequireAdmin

; Gather basic information first, used for populating the GUI later on.
$OS = @OSVersion
$Hostname = @ComputerName
$arch = @ProcessorArch
Dim $resolution[4] = [@DesktopHeight, @DesktopWidth, @DesktopDepth,  @DesktopRefresh]
;MsgBox ( 0, "Info", $resolution[0] & "x" & $resolution[1] & " @ " & $resolution[2] & "bpp. Refresh: " & $resolution[3])
Dim $testServices[5][3] =  [["DAMaint","",""], _
                            ["DesktopAuthority","",""], _
                            ["SharedAccess","",""], _
                            ["SLClient","",""], _
                            ["Spooler","",""]]


#cs ##########
 CALL THE FUNCTIONS NOW....
#ce ##########
runningServices($serviceArray)
;Verify Services, Update Array
For $svcIndex = 0 To UBound($testServices)-1; each $testServices[0..2][0]
    serviceFind($serviceArray, $testServices[$svcIndex][0], $testServices[$svcIndex][1], $testServices[$svcIndex][2])
Next
_ArrayDisplay($testServices)


Func runningServices(ByRef $serviceArray)
; Gather the service info and put it into an easy to manipulate array.
    Local $localArray = 0
    $svcReturn = Run(@ComSpec & " /c sc query", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
; Each StdoutRead can be up to 64kb, Sets @error to non-zero if EOF is reached.
    $timetoLeave = 0
    while $timetoLeave == 0
        $line = StdoutRead($svcReturn)
        if @error <> 0 Then
;This @error comes from the StdoutRead.  had to use another var because the @error is reused on each loop...
            $timetoLeave=1
        Endif
        $localArray = StringSplit(StringStripCR($line), @LF)
        For $count = 0 to UBound($localArray,1) - 1
            $splitReturn = StringSplit($localArray[$count], ":")
            if $splitReturn[0] == 2 then
;remove WhiteSpace
                $splitReturn[1] = StringStripWS($splitReturn[1], 3)
                $splitReturn[2] = StringStripWS($splitReturn[2], 3)
                Select
                    Case $splitReturn [1] = "SERVICE_NAME"
                        _ArrayInsert2D( $serviceArray, $splitReturn)
                        
                    Case $splitReturn [1] = "DISPLAY_NAME"
                        _ArrayInsert2D( $serviceArray, $splitReturn)
                    
    ; Not using Case STATE because this seems only to pick up RUNNING services anyway... Probably a better way to catch non-running services, but will wait till later.
    ;Case $splitReturn [1] = "STATE" 
        ; cut off left most number and whitespace
    ;   $splitReturn[2] = StringTrimLeft ( $splitReturn[2], 2 )
    ;   $splitReturn[2] = StringStripWS($splitReturn[2], 3)
    ;   _ArrayInsert2D( $serviceArray, $splitReturn)
                EndSelect
            endif
        Next
    wend
EndFunc


; 
Func serviceFind(ByRef $serviceArray, ByRef $serviceName, ByRef $serviceDescrip, ByRef $serviceState)
; We are looking for Windows Firewall/Internet Connection Sharing (ICS), Service_Name: SharedAccess
;_ArrayDisplay($serviceArray)
; Assume 2D array here... maybe more later.
; Find the $serviceName
    For $r = 0 to UBound($serviceArray,1) - 1
        For $c = 0 to UBound($serviceArray,2) - 1

            if $serviceName == $serviceArray[$r][$c] Then
                $serviceDescrip = $serviceArray[$r+1][$c]; It's +1 because the array was loaded with ServiceName and then DisplayName.
                $serviceState = "Running"
                
            EndIf
        Next
    Next
EndFunc

; Function _ArrayInsert2D, this is from autoit forums, made by user randallc
Func _ArrayInsert2D(ByRef $avArray, $aRowArray, $nRow = '')
    Local $number_of_columns = UBound($avArray, 2), $number_of_rows = UBound($avArray), $nSize = 0, $arraysize
    If $number_of_columns < (UBound($aRowArray)) Then $number_of_columns = UBound($aRowArray)
    If $nRow > $number_of_rows - 1 Then
        SetError(2)
        Return (2)
    EndIf
    If $avArray[0][0] <> '' Or UBound($avArray) - 1 > 0 Then $number_of_rows = $number_of_rows + 1
    If $number_of_columns < UBound($aRowArray) Then $number_of_columns = UBound($aRowArray)
    ReDim $avArray[$number_of_rows ][$number_of_columns]
    If $nRow == '' Then
        $arraysize = UBound($aRowArray);Find array size
        For $c = 0 To $arraysize - 1
            $avArray[$number_of_rows - 1][$c] = $aRowArray[$c]
        Next
        SetError(0)
        Return (0)
    EndIf
    For $r = $number_of_rows - 1 To $nRow Step - 1
        For $c = 0 To UBound($avArray, 2) - 1
            If $r <> $nRow Then
                $avArray[$r][$c] = $avArray[$r - 1][$c]
                $avArray[$r - 1][$c] = ''
            Else
                If Not ($c > UBound($aRowArray) - 1) Then
                    $avArray[$r][$c] = $aRowArray[$c]
                EndIf
            EndIf
        Next
    Next
    SetError(0)
    Return (0)
EndFunc;==>_ArrayInsert2D
Edited by laidback01

Share this post


Link to post
Share on other sites



Is this so bad it warrants no reply? Or is it just the Christmas holiday keeping ppl away?

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  
Followers 0