$=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) "Checking for Branding..."
Sleep 1
CLS
Break ON CLS
If Exist($DBpath) = 0 ;Abort if no Database exists when using an access database.
? "Branding Database Not Found. Aborting..."
Sleep 1
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 compname = '@WKSTA'"
$cn = CreateObject ("ADODB.Connection")
$cmd = CreateObject ("ADODB.Command")
$rs = CreateObject ("ADODB.RecordSet")
$cn.connectionstring = $CNstring
$cn.Open
$cmd.activeconnection = $cn
QueryBranded($cn, $cmd, $rs, $CNstring, $CMDtxt, $DBfile)
$cn.close
$x=MessageBox("Done!","Branding Collection", 4096)
Exit 1
EndFunction
;*** COLLECT BRANDING INFORMATION
Function QueryBranded($cn, $cmd, $rs, $CNstring, $CMDtxt, $DBfile)
Dim $CMDtxt, $CompName, $ModifyDate, $cmd, $rs
? "Querying Branding Information"
$rs.cursortype = 3
$rs.locktype = 3
$rs.activecommand = $cmd
$cmd.commandtext = $CMDtxt $rs.Open ($cmd)
;**** Set Variables ****
$ModifyDate = @DATE
$CompName = @WKSTA
$Search1 = "c:\windows\system\oeminfo.ini"
$Search2 = "c:\windows\system32\oeminfo.ini"
$Branded = "blank"
$FindString = "Your String Here"
$Found = "blank"
$ModifyDate = @DATE
If $rs.eof = -1
$rs.addnew
EndIf
;Check for file existence and check for the $FindString
$Found = ReadProfileString($Search1, "Support Information", "Line3")
$Found = ReadProfileString($Search2, "Support Information", "Line3")
$Branded = IIF($Found = $Findstring, "True", "False")
$rs.fields.item("COMPNAME").value = $CompName
$rs.fields.item("Branded").value = $Branded
$rs.fields.item("MODIFYDATE").value = $ModifyDate
$rs.update
$rs.Close
EndFunction