$=setoption("wrapateol","on")
Dim $DBpath, $DBFile
;$DBpath = @Scriptdir ;Modify this to represent your database location if using an access database.
$DBpath = "F:\New Folder"
$DBfile = $DBpath +"\Computers.mdb"
CLS
At (5,1) "Asset Audit Script Processing..."
Sleep 2
CLS
Break ON CLS
If Exist($DBpath) = 0 ;Abort if no Database exists when using an access database.
? "IT Assets Database Not Found. Aborting..."
Sleep 3
Exit 1
Else
Main($DBFile)
EndIf
Function Main($DBFile)
Dim $CNstring, $CMDtxt, $cn, $cmd, $rs
;*** CONFIGURE DATABASE CONNECTION STRING ***
$CNstring="Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DBFile" ;Next line for sql server
;$CNstring = "Driver={SQL Server};Server=MyServer;database=MyDatabase;uid=UserName;pwd=password"
$CMDtxt = "select * from Branded where computername = '@WKSTA'"
$cn = CreateObject ("ADODB.Connection")
$cmd = CreateObject ("ADODB.Command")
$rs = CreateObject ("ADODB.RecordSet")
$cn.connectionstring = $CNstring
$cn.Open
$cmd.activeconnection = $cn
QueryLogon($cn, $cmd, $rs, $CNstring, $CMDtxt, $DBfile)
$cn.close
$x=MessageBox("Done!","Data Collection", 4096)
Exit 1
EndFunction
;*** COLLECT WORKSTATION ASSET INFORMATION
;Queries Logon information, updates COMPUTERS table.
Function QueryLogon($cn, $cmd, $rs, $CNstring, $CMDtxt, $DBfile)
Dim $Search1, $Search2, $Branded, $FindString, $Found, $CMDtxt, $CompName, $ModifyDate, $cmd, $rs
? "Querying Logon Information"
$rs.cursortype = 3
$rs.locktype = 3
$rs.activecommand = $cmd
$cmd.commandtext = $CMDtxt $rs.Open ($cmd)
$ComputerName = @WKSTA
$ModifyDate = @DATE
;**** Set Variables ****
$CompName = @WKSTA
$Search1 = "c:\windows\system\oeminfo.ini"
$Search2 = "c:\windows\system32\oeminfo.ini"
$Branded = "blank"
$FindString = "Your text here"
$Found = "blank"
$ModifyDate = @DATE
;Check for file existence and check for the $FindString
$Branded = IIF(ReadProfileString($Search1, "Support Information", "Line3"), "True", "False")
$Branded = IIF(ReadProfileString($Search2, "Support Information", "Line3"), "True", "False")
If $Branded = "True"
$Found = ReadProfileString($Search1, "Support Information", "Line3")
$Found = ReadProfileString($Search2, "Support Information", "Line3")
Else
$Found = "False"
Endif
? $CompName
;? $Search1
;? $Search2
? $Branded
? $FindString
? $Found
? $ModifyDate
Get $x
If $rs.eof = -1
$rs.addnew
EndIf
$rs.fields.item("COMPNAME").value = $CompName
$rs.fields.item("Branded").value = $Branded
$rs.fields.item("MODIFYDATE").value = $ModifyDate
$rs.update
$rs.Close
Exit @error
EndFunction