CLPowell
Getting the hang of it
Registered: 2000-05-08
Posts: 59
Loc: San Angelo, Texas, USA 76903
|
;I have 2 scripts that Do basically the same thing with ;differant output types. My challenge is that the first ;script writes to a text file AND lists 36 installed ;programs (on my wksta) AND the second writes to a database AND lists ;only 16 (on same wksta). I am on my third day fighting this one AND I ;turn to the board For help.
;**** FIRST SCRIPT WITH TEXT OUTPUT******** $LogDir = "\\fdadmfs1\inventory$$" $WSInfoFile = %TEMP% + "\" + @WkSta + ".ini" Del $WSInfoFile $RC = WriteProfileString("$WSInfoFile","WsInfo","WsName","@WkSta") $RC = WriteProfileString("$WSInfoFile","LogonInfo","Date","@DATE") $RC = WriteProfileString("$WSInfoFile","LogonInfo","Time","@Time") $RC = WriteProfileString("$WSInfoFile","LogonInfo","Logon server","@LServer") $RC = WriteProfileString("$WSInfoFile","UserInfo","UserID","@UserID") $RC = WriteProfileString("$WSInfoFile","UserInfo","Fullname","@FullName") $RC = WriteProfileString("$WSInfoFile","UserInfo","Comment","@Comment") $RC = WriteProfileString("$WSInfoFile","UserInfo","Privilege","@Priv") $num = 1 $RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" Gosub GetProgInfo Shell '%COMSPEC% /C Copy "$WSInfoFile" "$LogDir" >Nul' Return :GetProgInfo $Index = 0 $Key = EnumKey($RootKey, $Index) While @Error = 0 $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf $RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Num", "$Value") $Num = $Num + 1 EndIf $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop Return :END
;****SECOND SCRIPT WITH DB OUTPUT *** ; must have an access mdb named swinv.mdb with the following table and fields ; Table - inventory ; Fields - computername, program, date, time
$DBpath = "\\fdadmfs1\inventory$$\swinv.mdb" If Exist("$DBpath") = 0 ? "Database Not Found. Aborting..." Sleep 3 Goto end EndIf $CNstring = "provider=microsoft.jet.oledb.4.0;data source=$DBpath;persist security info=false" $CMDtxt = "select * from Inventory" $cn = CreateObject ("ADODB.Connection") $cmd = CreateObject ("ADODB.Command") $rs = CreateObject ("ADODB.RecordSet") $cn.connectionstring = $CNstring $cn.Open $cmd.activeconnection = $cn $rs.cursortype = 3 $rs.locktype = 3 $rs.activecommand = $cmd $cmd.commandtext = $CMDtxt $rs.Open ($cmd) $RootKeydb = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" Gosub GetInfo Return :GetInfo $Indexdb = 0 $Keydb = EnumKey($RootKeydb, $Indexdb) While @Error = 0 $RC = EnumValue($RootKeydb + $Keydb, 1) If @Error = 0 $Valuedb = ReadValue($RootKeydb + $Keydb, "DisplayName") If $Valuedb = "" $Valuedb = ReadValue($RootKeydb + $Keydb, "QuietDisplayName") If $Valuedb = "" $Valuedb = $Keydb EndIf EndIf $rs.addnew $rs.fields.item("computername").value = @WKSTA $rs.fields.item("program").value = $valuedb $rs.fields.item("date").value = @DATE $rs.fields.item("time").value = @TIME $rs.update EndIf $Indexdb = $Indexdb + 1 $Keydb = EnumKey($RootKeydb, $Indexdb) Loop $rs.Close Return :END
_________________________
Chris Powell Fire Technology Manager
|