#70303 - 2002-09-27 01:36 PM
Softwhere? - the latest update
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
Originally started in this thread.
What is Softwhere? Softwhere is a GUI script that is designed to inventory and report software installed across a network.
All files pictures and the script are contained here. http://www.geocities.com/greenmaze/softwhere/
The script was renamed to a txt file because google sucks.
Features Scan computers across a network one at a time or as many as you want at a time.
Manage scan loggs based on age.
Easily add computers to the database as well as delete the entire database.
A form to view software installed on a computer and another form to view what computers a piece of software is installed on.
Create html reports based off of the forms mentioned above.
Requires Kixtart v2001 4.12 Beta 1 Kixforms v2.0.5 Both available at http://www.kixforms.freeuk.com NetView2 UDF SerialDate UDF
Setup Edit the first two lines and point them to the UDFs specified in the requirements.
Download the Access database inventory.mdb.
The first time you run the script it will ask you to specify a few directories. Make sure you end these directories with a \. Example: E:\loggs\
code:
Call ("E:\kix\UDF\NetView2.UDF") Call ("E:\kix\UDF\SerialDate.UDF")
Break on
Dim $SearArr, $ComputerArr, $Array1, $Array2, $DBMg1[1], $Comprenew
$FORM = CreateObject("Kixtart.FORM")
$FORM.CAPTION = "Softwhere" $FORM.HEIGHT = 350 $FORM.WIDTH = 210 $FORM.FONTNAME = "Arial" $FORM.FONTSIZE = 9 $FORM.CENTER $FORM.BorderStyle = 2
$SoftPict = $Form.PictureBox(,1,3,$FORM.Width-12,$FORM.Height/8) $SoftPict.BackColor = 255,255,255 $SoftPict.ForeColor = 0,100,100 $SoftPict.FONTNAME = "verdana" $SoftPict.FONTSIZE = 20 $SoftPict.PrintXY(20,3,"Softwhere?") $ScanButton = $FORM.CommandButton("Scan Computers",3,$SoftPict.Height+$SoftPict.Top+4,$FORM.Width-12,$FORM.Height/8) $DBMgButton = $FORM.CommandButton("Database Management",3,$ScanButton.Top+$ScanButton.Height+4,$FORM.Width-12, $FORM.Height/8) $SoftButton = $FORM.CommandButton("Search for Software by Computer",3,$DBMgButton.Height+$DBMgButton.Top+4,$FORM.Width-12, $FORM.Height/8) $CompButton = $FORM.CommandButton("Search for Computer by Software",3,$SoftButton.Height+$SoftButton.Top+4,$FORM.Width-12, $FORM.Height/8) $SetupButton = $FORM.CommandButton("Softwhere Setup",3,$CompButton.Height+$CompButton.Top+4,$FORM.Width-12,$FORM.Height/8) $QuitButton = $FORM.CommandButton("Quit",3,$SetupButton.Top + $SetupButton.Height + 4,$FORM.Width-12,$FORM.Height/8-8) $ScanButton.OnClick = '$$ScanForm.Show' $DBMgButton.OnClick = '$$DBManage.Show $$DBMg = DirAgeList($$loggpath) $$FileBox.List = $$DBMg[0]' $SoftButton.OnClick = '$$ReportLstBox.Clear redim $$ReportArr $$ReportFrm.Show $$CompForm.Show $$ReturnData=GetDBData() $$CompArr = CompForm($$ReturnData)' $CompButton.OnClick = '$$ReportLstBox.Clear redim $$ReportArr $$ReportFrm.Show $$SoftForm.Show $$ReturnData2=GetDBData() $$SoftArr = SoftForm($$ReturnData2)' $SetupButton.OnClick = '$$SofSetup.Show' $QuitButton.OnClick = 'Quit()'
$ScanForm = CreateObject("Kixtart.FORM") $ScanForm.CAPTION = "Scan Computers" $ScanForm.HEIGHT = 320 $ScanForm.WIDTH = 517 $ScanForm.FONTNAME = "Arial" $ScanForm.FONTSIZE = 9 $ScanForm.CENTER $ScanForm.BorderStyle = 2 $FraScan = $ScanForm.Frame("",5,5,$ScanForm.WIDTH-17,$ScanForm.HEIGHT-35) $ScanCompTxt = $FraScan.Label("Computer",10,15,60,15) $ScanCompBox = $FraScan.TextBox("",10,$ScanCompTxt.Top+$ScanCompTxt.Height+2,150,20) $ScanDomainTxt = $FraScan.Label("Domain",10,$ScanCompBox.Top+$ScanCompBox.Height+7,60,15) $ScanDomainBox = $FraScan.TextBox("@Domain",10,$ScanDomainTxt.Top+$ScanDomainTxt.Height+2,150,20) $ScanCompLB = $FraScan.ListBox(,10,$ScanDomainBox.Top+$ScanDomainBox.Height+2,150,180-2)
$ScanCompLB.OnDoubleClick= 'ReDim preserve $$ComputerArr[Ubound($$ComputerArr)+1] $$ComputerArr[Ubound($$ComputerArr)] = $$ScanCompLB.text $$TargetComp.AddItem ($$ScanCompLB.Value) $$ScanCompLB.RemoveItem ($$ScanCompLB.Listindex)' $AddComp = $FraScan.CommandButton("Add",$ScanCompBox.Left+$ScanCompBox.Width+5,$ScanCompBox.Top,50,$ScanCompBox.Height) $AddComp.OnClick = 'if $$ScanCompBox.Text <> "" $$TargetComp.AddItem ($$ScanCompBox.Text) ReDim preserve $$ComputerArr[Ubound($$ComputerArr)+1] $$ComputerArr[Ubound($$ComputerArr)] = $$ScanCompBox.Text $$ScanCompBox.Text = "" $$NoLogg.Enabled = 1 $$LoggOlder.Enabled = 1 EndIf $$ScanCompBox.SetFocus' $ListDomain = $FraScan.CommandButton("List",$AddComp.Left,$ScanDomainBox.Top,$AddComp.Width,$AddComp.Height) $ListDomain.OnClick = '$$CompListArr = netview2($$ScanDomainBox.Text) $$ScanCompLB.List = $$CompListArr' $AddComp2 = $FraScan.CommandButton("Add",$AddComp.Left,$ScanCompLB.Top,$AddComp.Width,$AddComp.Height) $AddComp2.OnClick = 'if $$ScanCompLB.Value <> "" $$TargetComp.AddItem ($$ScanCompLB.Value) ReDim preserve $$ComputerArr[Ubound($$ComputerArr)+1] $$ComputerArr[Ubound($$ComputerArr)] = $$ScanCompLB.text $$ScanCompLB.RemoveItem ($$ScanCompLB.Listindex) $$ScanCompLB.SetFocus $$=SendKeys({down}{down}) $$NoLogg.Enabled = 1 $$LoggOlder.Enabled = 1 EndIf' $AddAll2 = $FraScan.CommandButton("Add All",$AddComp.Left,$AddComp2.Top+$AddComp2.Height+2,$AddComp.Width,$AddComp.Height) $AddAll2.OnClick = '$$ScanCompLB.SetFocus $$=SendKeys({up}) if $$ScanCompLB.Value <> "" for each $$target in $$complistarr $$TargetComp.additem ($$target) ReDim preserve $$ComputerArr[Ubound($$ComputerArr)+1] $$ComputerArr[Ubound($$ComputerArr)] = $$target Next $$ScanCompLB.Clear $$NoLogg.Enabled = 1 $$LoggOlder.Enabled = 1 EndIf' $ChosenCompLst = $FraScan.Label("Selected Computers",$AddComp.Left+$AddComp.Width+5,$ScanCompTxt.Top,200,15) $TargetComp = $FraScan.ListBox(,$ChosenCompLst.Left,$ScanCompBox.Top,$ScanCompLB.Width,$ScanCompLB.Height+65+1) $RemoveComp = $FraScan.CommandButton("Remove from list",$TargetComp.Left+$TargetComp.Width+5,$TargetComp.Top,115,20) $RemoveComp.OnClick = 'if $$TargetComp.Text <> "" $$TargetCompText = $$TargetComp.Text $$ComputerArr = RemFromArray($$ComputerArr,$$TargetCompText) $$TargetComp.RemoveItem ($$TargetComp.Listindex) $$TargetComp.SetFocus $$=SendKeys({down}{down}) EndIf' $RemoveAll = $FraScan.CommandButton("Remove All", $RemoveComp.Left,$RemoveComp.Top+$RemoveComp.Height+2,$RemoveComp.Width,20) $RemoveAll.OnClick = '$$TargetComp.Clear redim $$COmputerArr $OlderBox.Enabled = 0 $NoLogg.Enabled = 0 $LoggOlder.Enabled = 0 $OlderListCB.Enabled = 0' $ShowLbl = $FraScan.Label("Show computers with",$RemoveComp.Left,$RemoveAll.Top+$RemoveAll.Height+10,$RemoveComp.Width+7,15) $NoLogg = $FraScan.CheckBox("no logg file",$RemoveComp.Left,$ShowLbl.Top+$ShowLbl.Height+5,$RemoveComp.Width,15) $LoggOlder = $FraScan.CheckBox("logg file older than specified days",$RemoveComp.Left,$NoLogg.Top+$NoLogg.Height+5, $RemoveComp.Width+8,30) $OlderBox = $FraScan.Textbox("0",$RemoveComp.Left,$LoggOlder.Top+$LoggOlder.Height+2,30,20) $OlderListCB = $FraScan.CommandButton("List",$OlderBox.Left+$OlderBox.Width+5,$OlderBox.Top,40,20) $LoggOlder.Onclick = 'if $$LoggOlder.Value = 1 $$OlderBox.Enabled = 1 $$NoLogg.Enabled = 0 $$OlderListCB.Enabled = 1 Else $$OlderBox.Enabled = 0 $$NoLogg.Enabled = 1 $$OlderListCB.Enabled = 0 EndIf ' $NoLogg.Onclick = 'if $$NoLogg.Value = 1 $$LoggOlder.Enabled = 0 $$CheckAge = DirAgeList($$Loggpath) For Each $$chkcomp in $$CheckAge[2] $$ComputerArr = RemFromArray($$ComputerArr,$$chkcomp) Next Else $$LoggOlder.Enabled = 1 EndIf $$TargetComp.List = $$ComputerArr' $OlderListCB.Onclick = 'if $$OlderBox.Text <> "" $$comparedate = serialdate(@@date) - $$OlderBox.Text $$CheckAge = DirAgeList($$Loggpath) For Each $$chkcomp in $$ComputerArr $$chkcount = 0 For Each $$chkcomp2 in $$Checkage[2] If $$chkcomp = $$chkcomp2 If $$Checkage[1][$$chkcount] =< $$comparedate ReDim preserve $$Comprenew[Ubound($$Comprenew)+1] $$Comprenew[Ubound($$Comprenew)] = $$chkcomp EndIf EndIf $$chkcount = $$chkcount+1 Next Next $$ComputerArr = $$Comprenew $$TargetComp.Clear $$TargetComp.List = $$ComputerArr ReDim $$Comprenew EndIf' $OlderBox.Enabled = 0 $NoLogg.Enabled = 0 $LoggOlder.Enabled = 0 $OlderListCB.Enabled = 0
$ScanList = $FraScan.CommandButton("Scan List",$RemoveAll.Left,$TargetComp.Top+$TargetComp.Height-62,$RemoveAll.Width,40) $ScanList.Onclick = '$$DataCmDBt.Enabled = 0 $$DataOut.Show SoftwareScan($$ComputerArr,$$loggpath)' $ExitScan = $FraScan.CommandButton("Exit",$ScanList.Left,$ScanList.top+$ScanList.height+2,$ScanList.width,20) $ExitScan.Onclick = '$$Scanform.Show(0)'
$DataOut = CreateObject("Kixtart.FORM") $DataOut.CAPTION = "" $DataOut.HEIGHT = 378 $DataOut.WIDTH = 500 $DataOut.FONTNAME = "Arial" $DataOut.FONTSIZE = 9 $DataOut.CENTER $DataListBx = $DataOut.ListBox(,5,5,484,315) $DataCmDBt = $DataOut.CommandButton("Done",395,$DataListBx.Top + $DataListBx.Height+5,95,25) $DataCmDBt.Enabled = 0 $ProgData = $DataOut.ProgressBar(,5,$DataCmDBt.Top,385,25) $DataCmDBt.OnClick = '$$DataOut.Show(0) $$DataListBx.Clear'
$DBManage = CreateObject("Kixtart.FORM") $DBManage.CAPTION = "Database Management" $DBManage.HEIGHT = 320 $DBManage.WIDTH = 470 $DBManage.FONTNAME = "Arial" $DBManage.FONTSIZE = 9 $DBManage.CENTER $DBManage.BorderStyle = 2 $FraDB = $DBManage.Frame("",5,5,$DBManage.WIDTH-17,$DBManage.HEIGHT-35) $FileLbl = $FraDB.Label("Files in Logg directory",10,10,170,15) $FileBox = $FraDB.ListBox(,$FileLbl.Left,$FileLbl.Top+$FileLbl.Height+2,200,250) $FraDel = $FraDB.Frame("",$FileBox.Left+$FileBox.width+10,0,$FraDB.Width-$FileBox.Width-21,110) $RecordBn = $FraDel.CommandButton("Delete all records in database",10,15,210,25) $LoggBn = $FraDel.CommandButton("Delete all logg files",10,$RecordBn.Top+$RecordBn.Height+5,210,25) $DayLoggBn = $FraDel.CommandButton("Delete logg files over",10,$LoggBn.Top+$LoggBn.Height+5,130,25) $DaysTxt = $FraDel.TextBox("0",$DayLoggBn.Left+$DayLoggBn.Width+3,$DayLoggBn.TOp,30,$DayLoggBn.Height-2) $DaysLbl = $FraDel.Label("days old",$DaysTxt.Left+$DaysTxt.Width+3,$DaysTxt.Top+3,50,15) $Parseone = $FraDB.CommandButton("Parse selected logg file now",$FraDel.Left+10,$FraDel.Height+10,$RecordBn.Width, $RecordBn.Height) $ParseAll = $FraDB.CommandButton("Parse all logg files now",$FraDel.Left+10,$Parseone.Top+$Parseone.Height+5, $RecordBn.Width,$RecordBn.Height) $DBExit = $FraDB.CommandButton("Exit",$FraDel.Left+10,$FileBox.Top+$FileBox.Height-$RecordBn.Height,$RecordBn.Width, $RecordBn.Height) $RecordBn.Onclick = 'Cleardatabase()' $LoggBn.Onclick = '$$FileBox.Clear for each $$delfil in $$DBMg[0] del "$$loggpath$$delfil" next' $DayLoggBn.Onclick = '$$delcoun = 0 for each $$delfile in $$DBMg[0] if $$DBMg[1][$$delcoun] > SerialDate(@@date)-$$DaysTxt.Value ReDim preserve $$Array1[Ubound($$Array1)+1] ReDim preserve $$Array2[Ubound($$Array2)+1] $$Array1[Ubound($$Array1)] = $$DBMg[0][$$delcoun] $$Array2[Ubound($$Array2)] = $$DBMg[1][$$delcoun] Else Del "$$loggpath$$delfile" EndIf $$delcoun = $$delcoun+1 Next $$FileBox.Clear $$FileBox.List = $$Array1 $$DBMg1[0] = $$Array1 $$DBMg1[1] = $$Array2 $$DBMg = $$DBMg1 ReDim $$Array1, $$Array2' $Parseone.Onclick = '$$DataCmDBt.Enabled = 0 $$DataOut.Show ParsetoDB($$FileBox.text,$$Loggpath)' $ParseAll.Onclick = '$$DataCmDBt.Enabled = 0 $$DataOut.Show ParsetoDB($$DBMg[0],$$Loggpath)' $DBExit.OnClick = '$$DBManage.Show(0)'
$CompForm = CreateObject("Kixtart.FORM") $CompForm.CAPTION = "Search for Software by Computer" $CompForm.HEIGHT = 485 $CompForm.WIDTH = 385 $CompForm.FONTNAME = "Arial" $CompForm.FONTSIZE = 9 $CompForm.CENTER $FraComp = $CompForm.Frame("",5,5,368,450) $SelCompTxt = $FraComp.Label("Select a Computer:",10,20,150,20) $SelCompBox = $FraComp.ListBox(,10,40,190,150) $InsProTxt = $FraComp.Label("Installed Programs:",10,200,150,20) $InsProBox = $FraComp.ListBox(,10,220,345,190) $ExitButton = $FraComp.CommandButton("Exit",210,160,150-2,30) $AddAllReport = $FraComp.CommandButton("Add all to report",210,40,150-2,30) $AddtoReport = $FraComp.CommandButton("Add to report",210,70,150-2,30) $CreateReport = $FraComp.CommandButton("Create report",210,100,150-2,30) $ClearReport = $FraComp.CommandButton("Remove all from report",210,130,150-2,30) $ProgComp = $FraComp.ProgressBar(,10,420,347,20) $SelCompBox.Sorted = 1 $InsProBox.Sorted = 1 $ProgComp.Min = 0 $ExitButton.OnClick = '$$CompForm.Show(0) $$ReportFrm.Show(0) $$SelCompBox.Clear $$InsProBox.Clear' $SelCompBox.OnClick = '$$InsProBox.List = GetInfo($$SelCompBox.Value,$$0,$$1,$$ReturnData)' $AddAllReport.OnClick = '$$ReportLstBox.List = $$CompArr $$ReportArr = $$CompArr' $AddtoReport.OnClick = 'if $$SelCompBox.Text <> "" $$ReportLstBox.AddItem ($$SelCompBox.Text) redim preserve $$reportarr[Ubound($$reportarr)+1] $$reportarr[Ubound($$reportarr)] = $$SelCompBox.Text EndIf' $CreateReport.OnClick = 'Report($$ReturnData,$$ReportArr,$$CompForm.CAPTION)' $ClearReport.OnClick = '$$ReportLstBox.Clear redim $$ReportArr'
$SoftForm = CreateObject("Kixtart.FORM") $SoftForm.CAPTION = "Search for Computer by Software" $SoftForm.HEIGHT = 485 $SoftForm.WIDTH = 385 $SoftForm.FONTNAME = "Arial" $SoftForm.FONTSIZE = 9 $SoftForm.CENTER $FraSoft = $SoftForm.Frame("",5,5,368,450) $SelProgTxt = $FraSoft.Label("Select Software:",10,20,150,20) $SelProBox = $FraSoft.ListBox(,10,40,345,190) $InsCompTxt = $FraSoft.Label("Installed on this Computer:",10,240,150,20) $InsCompBox = $FraSoft.ListBox(,10,260,190,150) $ExitButton2 = $FraSoft.CommandButton("Exit",210,380,150-2,30) $AddAllReport2 = $FraSoft.CommandButton("Add all to report",210,260,150-2,30) $AddtoReport2 = $FraSoft.CommandButton("Add to report",210,290,150-2,30) $CreateReport2 = $FraSoft.CommandButton("Create report",210,320,150-2,30) $ClearReport2 = $FraSoft.CommandButton("Remove all from report",210,350,150-2,30) $ProgSoft = $FraSoft.ProgressBar(,10,420,347,20) $SelProBox.Sorted = 1 $InsCompBox.Sorted = 1 $ExitButton2.OnClick = '$$SoftForm.Show(0) $$ReportFrm.Show(0) $$SelProBox.Clear $$InsCompBox.Clear' $AddAllReport2.OnClick = '$$ReportLstBox.List = $$SoftArr $$ReportArr = $$SoftArr' $AddtoReport2.OnClick = 'if $$SelProBox.Text <> "" $$ReportLstBox.AddItem ($$SelProBox.Text) redim preserve $$reportarr[Ubound($$reportarr)+1] $$reportarr[Ubound($$reportarr)] = $$SelProBox.Text EndIf' $CreateReport2.OnClick = 'Report($$ReturnData2,$$ReportArr,$$SoftForm.CAPTION)' $ClearReport2.OnClick = '$$ReportLstBox.Clear redim $$ReportArr' $SelProBox.OnClick = '$$InsCompBox.List = GetInfo($$SelProBox.Value,$$1,$$0,$$ReturnData2)'
$SofSetup = CreateObject("Kixtart.FORM") $SofSetup.CAPTION = "Softwhere Setup" $SofSetup.HEIGHT = 195 $SofSetup.WIDTH = 310 $SofSetup.FONTNAME = "Arial" $SofSetup.FONTSIZE = 9 $SofSetup.CENTER $SofSetup.BorderStyle = 2 $SetupLgPthlbl = $SofSetup.Label("Path to directiory where logg files will be maintained",10,10,290,15) $SetupLgPthbox = $SofSetup.Textbox("",10,$SetupLgPthlbl.Top+$SetupLgPthlbl.Height+2,200,20) $SetupDBPthlbl = $SofSetup.Label("Path to directory where the access database will be maintained",10, $SetupLgPthbox.Top+$SetupLgPthbox.Height+7,290,15) $SetupDBPthbox = $SofSetup.Textbox("",10,$SetupDBPthlbl.Top+$SetupDBPthlbl.Height+2,200,20) $SetupDBNamlbl = $SofSetup.Label("Name of the access database (must end in .mdb)",10,$SetupDBPthbox.Top+ $SetupDBPthbox.Height+7,290,15) $SetupDBNambox = $SofSetup.Textbox("",10,$SetupDBNamlbl.Top+$SetupDBNamlbl.Height+2,200,20) $SetupSavBtn = $SofSetup.CommandButton("Save Settings",60,$SetupDBNambox.Top+$SetupDBNambox.Height+7,90,20) $SetupExiBtn = $SofSetup.CommandButton("Exit",$SetupSavBtn.Left+$SetupSavBtn.Width+5,$SetupSavBtn.Top,90,20) $SetupSavBtn.OnClick = 'Select Case $$SetupLgPthBox.Text = "" ErrorMsg("Error","Logg path empty") Case $$SetupDBPthBox.Text = "" ErrorMsg("Error","Database path empty") Case $$SetupDBNambox.Text = "" ErrorMsg("Error","Database name empty") Case 1 $$SetupLgPthBox1 = $$SetupLgPthBox.text $$SetupDBPthBox1 = $$SetupDBPthBox.Text $$SetupDBNambox1 = $$SetupDBNambox.Text $$=WriteProfileString("%systemroot%\softwhere.ini","Defaults","LoggPath","$$SetupLgPthBox1") $$=WriteProfileString("%systemroot%\softwhere.ini","Defaults","DBPath","$$SetupDBPthBox1") $$=WriteProfileString("%systemroot%\softwhere.ini","Defaults","DBName","$$SetupDBNambox1") $$SetupLgPthBox1 = $$SetupLgPthBox.text $$SetupDBPthBox1 = $$SetupDBPthBox.Text $$SetupDBNambox1 = $$SetupDBNambox.Text $$SofSetup.Show(0) EndSelect' $SetupExiBtn.Onclick = 'Select Case $$SetupLgPthBox.Text = "" ErrorMsg("Error","Logg path empty") Case $$SetupDBPthBox.Text = "" ErrorMsg("Error","Database path empty") Case $$SetupDBNambox.Text = "" ErrorMsg("Error","Database name empty") Case 1 $$SofSetup.Show(0) EndSelect' $SetupLgPthBox.Text = ReadProfileString("%systemroot%\softwhere.ini","Defaults","LoggPath") $SetupDBPthBox.Text = ReadProfileString("%systemroot%\softwhere.ini","Defaults","DBPath") $SetupDBNambox.Text = ReadProfileString("%systemroot%\softwhere.ini","Defaults","DBName") $DBPath = $SetupDBPthBox.Text $DBFile = $SetupDBNambox.Text $Loggpath = $SetupLgPthBox.Text
$ReportFrm = CreateObject("Kixtart.FORM") $ReportFrm.CAPTION = "Create Report" $ReportFrm.HEIGHT = 220 $ReportFrm.WIDTH = 300 $ReportFrm.FONTNAME = "Arial" $ReportFrm.FONTSIZE = 9 $ReportFrm.Location = 800,100 $ReportLstBox = $ReportFrm.Listbox(,5,5,283,165) $ReportProgg = $ReportFrm.ProgressBar("",5,$ReportLstBox.Top+$ReportLstBox.Height,283,20)
$FORM.Show $Form.SetFocus
$SetupLgPthBox1 = $SetupLgPthBox.text $SetupDBPthBox1 = $SetupDBPthBox.Text $SetupDBNambox1 = $SetupDBNambox.Text If $SetupLgPthBox1 = "" OR $SetupDBPthBox1 = "" OR $SetupDBNambox1 = "" ErrorMsg("Error","Please enter defaults in softwhere setup") $SofSetup.Show EndIf
While $FORM.Visible OR $CompForm.Visible OR $SoftForm.Visible OR $ScanForm.Visible OR $SofSetup.Visible $=Execute($FORM.DoEvents) Loop
Function ErrorMsg($1,$2) $= $Form.MsgBox($2,$1) EndFunction
Function CompForm($ReturnData) $1=1 $0=0 $CompForm.SetFocus $ProgComp.Max = Val(Ubound($ReturnData[0])) $CompArr = StripCopies($ReturnData[0]) $SelCompBox.List = $CompArr $CompForm = $CompArr EndFunction
Function SoftForm($ReturnData) $1=1 $0=0 $SoftForm.SetFocus $ProgSoft.Max = Val(Ubound($ReturnData[1])) $SoftArr = StripCopies($ReturnData[1]) $SelProBox.List = $SoftArr $SoftForm = $SoftArr EndFunction
Function GetDBData() Dim $CompArr Dim $ProgArr Dim $DBArr[2] $connect = CreateObject("ADODB.Connection") $connectstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$DBPath$DBFile" $connect.Open($connectstring) $queryDB = "SELECT * FROM TBL_PROGRAM" $queryDB = $connect.Execute($queryDB) While NOT $queryDB.EOF $dataComp=$queryDB.Fields("Computer").value $dataProg=$queryDB.Fields("Program").value $queryDB.movenext ReDim preserve $CompArr[Ubound($CompArr)+1] ReDim preserve $ProgArr[Ubound($ProgArr)+1] $CompArr[Ubound($CompArr)] = $dataComp $ProgArr[Ubound($ProgArr)] = $dataprog Loop $connect.Close $DBArr[0] = $CompArr $DBArr[1] = $ProgArr $GetDBData = $DBArr EndFunction
Function GetInfo($SearchFor,$SMultiNum,$RMultiNum,$Array) Dim $InfoArray $inter = 0 For Each $find in $Array[$SMultiNum] If $find = "$SearchFor" ReDim preserve $InfoArray[Ubound($InfoArray)+1] $InfoArray[Ubound($InfoArray)] = $Array[$RMultiNum][$inter] EndIf $inter = $inter + 1 Next $GetInfo = $InfoArray EndFunction
Function StripCopies($striArray) $on = 1 Dim $searArr,$a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p, $q,$r,$s,$t,$u,$v,$w,$x,$y,$z,$0,$1,$2,$3,$4,$5,$6,$7,$8,$9 For Each $add in $StriArray $dyn = SubStr($add,1,1) $nul = Execute('if ubound($$$dyn) = -1 ReDim $$$dyn[0] $$$dyn[Ubound($$$dyn)] = $$add EndIf $$counter = 0 While Ubound($$$dyn)+1 <> $$counter If $$add = $$$dyn[$$counter] $$on = 1 EndIf $$counter = $$counter+1 Loop $$counter = 0 If $$on = 0 ReDim preserve $$$dyn[Ubound($$$dyn)+1] $$$dyn[Ubound($$$dyn)] = $$add EndIf') $on = 0 $ProgComp.Value = $ProgComp.Value+1 $ProgSoft.Value = $ProgSoft.Value+1 Next $ProgComp.Value = 0 $ProgSoft.Value = 0 $count = 48 While $count <> 91 $dyna = Chr($count) $nul = Execute(' For Each $$addto in $$$dyna ReDim preserve $$seararr[Ubound($$seararr)+1] $$seararr[Ubound($$seararr)] = $$addto Next') $count = $count + 1 If $count = 58 $count = $count + 7 EndIf Loop $StripCopies = $SearArr EndFunction
Function SoftwareScan($CompArr,$loggpath) Dim $computer Dim $programs Dim $Subkeys $ProgData.Max = Ubound($CompArr)+1 For Each $computer in $Comparr Shell '%comspec% /c ping -n 1 $computer | find /i "(0% loss)" > ping.dat' If GetFileSize("ping.dat") <> 0 $DataListBx.Additem ("$computer Network connectivity present") $DataListBx.Additem ("Scanning $computer") $index = -1 While @error = 0 ReDim preserve $subkeys[Ubound($subkeys)+1] $index = $index+1 $subkeys[Ubound($subkeys)] = EnumKey("\\$Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",$index) Loop If Ubound($subkeys) = 0 $DataListBx.Additem ("** Could not collect information from $computer **") EndIf For Each $key in $subkeys $Displayname = ReadValue ("\\$Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$key","Displayname") If $Displayname <> "" ReDim preserve $programs[Ubound ($programs)+1] $programs[Ubound($programs)] = $Displayname EndIf Next $nul = ReDirectOutput ("$loggpath$computer.log",1) join($programs,"~*~") $nul = ReDirectOutput("") ReDim $programs, $subkeys $DataListBx.Additem ("Finished Scanning $computer") $DataListBx.ListIndex = $DataListBx.ListCount - 1 Del("ping.dat") Else $DataListBx.Additem ("** Could Not connect to $computer **") $DataListBx.ListIndex = $DataListBx.ListCount - 1 EndIf $DataListBx.Additem (" ") $DataListBx.ListIndex = $DataListBx.ListCount - 1 $ProgData.Value = $ProgData.Value+1 Next $ProgData.Value = 0 $DataCmDBt.Enabled = 1 EndFunction
Function DirAgeList($directory) Dim $computer, $Age, $file, $computername, $DirAge[2] $file = Dir("$directory*.log") While @error = 0 ReDim preserve $computer[Ubound($Computer)+1] ReDim preserve $Age[Ubound($Age)+1] ReDim preserve $computername[Ubound($computername)+1] $Computer[Ubound($computer)] = $file $Age[Ubound($Age)] = SerialDate(SubStr(GetFileTime("$directory"+"$file"),1,10)) $computername[Ubound($computername)] = SubStr($file,1,InStr($file,".")-1) $file = Dir() Loop $DirAge[0] = $computer $DirAge[1] = $age $DirAge[2] = $computername $DirAgeList = $DirAge EndFunction
Function RemFromArray($Array,$Remove) Dim $JoinAr, $Array, $Remove, $SplitAr $JoinAr = Join($Array,"~~") If InStr($joinar,"$remove") $SplitAr = SubStr($JoinAr,1,InStr($JoinAr,$Remove)-3)+SubStr($JoinAr,InStr($JoinAr,$Remove)+Len($Remove),) If SubStr($SplitAr,1,2) = "~~" $SplitAr = SubStr($SplitAr,3,)EndIf $RemFromArray = Split($SplitAr,"~~") Else $RemFromArray = $Array EndIf EndFunction
Function ParsetoDB($loggDir,$Loggpath) $ProgData.Max = Ubound($loggdir)+1 $RC=SetOption("WrapAtEOL","On") $DSN="Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DBPath$DBFile" $Connection = CreateObject("ADODB.Connection") $Command = CreateObject("ADODB.Command") $Recordset = CreateObject("ADODB.Recordset")
$Connection If @error = 0 $Connection.ConnectionString = $DSN $Connection.Open() $Command.ActiveConnection = $Connection $Recordset.CursorType = 3 $Recordset.LockType = 3 $Recordset.ActiveCommand = $Command If VarType($loggDir) = 8 Dim $2[0] $2[0] = $loggdir $loggdir = $2 EndIf For Each $1 in $loggDir $ProgData.Value = $ProgData.Value+1 $nul = Open(1,"$loggpath$1") If @error <> 0 $DataListBx.Additem ("$1 Error") $DataListBx.Additem ("@serror") $DataListBx.Additem (" ") $DataListBx.ListIndex = $DataListBx.ListCount - 1 EndIf $1 = SubStr($1,1,InStr($1,".log")-1) $ProgArray = ReadLine(1) If @error = 0 $ProgArray = Split($ProgArray,"~*~") For Each $program in $ProgArray If InStr($Program,"'") <> 0 $A = Split($Program,"'") For Each $B in $A $C=$C+$B Next $Program = $C $C="" EndIf $CHECK_ENTRY_PROGRAM = "SELECT * FROM TBL_PROGRAM WHERE COMPUTER='$1' AND PROGRAM='$program';" $Command.CommandText = $CHECK_ENTRY_PROGRAM $Recordset.Open($Command) If $Recordset.RecordCount < 1 $Recordset.AddNew If @ERROR <> 0 ?@SERROR EndIf $Recordset.Fields("Computer").Value = "$1" If @ERROR <> 0 ?@SERROR EndIf $Recordset.Fields("Program").Value = "$program" If @ERROR <> 0 ?@SERROR EndIf EndIf $Recordset.Update $Recordset.Close() Next $DataListBx.Additem ("$1 Completed Successfully") $DataListBx.Additem (" ") $DataListBx.ListIndex = $DataListBx.ListCount - 1 Else $DataListBx.Additem ("$1 @serror") $DataListBx.Additem (" ") $DataListBx.ListIndex = $DataListBx.ListCount - 1 EndIf $nul = Close(1) Next $Connection.Close() $Connection = 0 $Recordset = 0 $Command = 0 Else $DataListBx.Additem ("Error connecting to the database ") $DataListBx.Additem ("@serror ") $DataListBx.ListIndex = $DataListBx.ListCount - 1 EndIf $ProgData.Value = 0 $DataCmDBt.Enabled = 1 EndFunction
Function Cleardatabase() $RC=SetOption("WrapAtEOL","On") $DSN="Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DBPath$DBFile" $Connection = CreateObject("ADODB.Connection") $Command = CreateObject("ADODB.Command") $Recordset = CreateObject("ADODB.Recordset")
$Connection If @error = 0 ? "Connected" $Connection.ConnectionString = $DSN $Connection.Open() $Command.ActiveConnection = $Connection $Recordset.CursorType = 3 $Recordset.LockType = 3 $Recordset.ActiveCommand = $Command $DELETE_SQL = "DELETE FROM TBL_PROGRAM WHERE COMPUTER<>'*';" $Command.CommandText = $DELETE_SQL $Recordset.Open($Command) $Recordset.Update $Recordset.Close() ?"Completed Successfully" $Connection.Close() $Connection = 0 $Recordset = 0 $Command = 0 EndFunction
Function Report($3,$4,$5) $ReportProgg.Max = Ubound($4) $nul = ReDirectOutput("report.html",1) ?'<html>' ? ?'<head>' ?'<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">' ?'<title>SOFTWHERE REPORT</title>' ?'</head>' ? ?'<body>' ? ?'<p align="center"><font Color="#0000FF"><b><font size="5">SOFTWHERE</font><font size="5">' ?'REPORT</font></b></font></p>' ?'<p align="center"><b>'@Date'</b></p>' ?'<p align="left" style="margin-top: -10"> </p>' If $5 = "Search for Computer by Software" For Each $6 in $4 ?'<p align="left" style="margin-top: -10"><font color="#0000FF"><b>Program Name: </font>' '<font color="#FF0000">'$6'</font> </b></p>' $7 = getinfo($6,$1,$0,$3) For Each $8 in $7 ?'<p align="left" style="margin-top: -15"><b> ' ?$8'</b></p>' Next ?'<p align="left" style="margin-top: -15"> </p>' ReDim $7 $ReportProgg.Value = $ReportProgg.Value+1 Next Else For Each $6 in $4 ?'<p align="left" style="margin-top: -10"><font color="#0000FF"><b>Computer Name: </font>' ?'<font color="#FF0000">'$6'</font> </b></p>' $7 = getinfo($6,$0,$1,$3) For Each $8 in $7 ?'<p align="left" style="margin-top: -15"><b> ' ?$8'</b></p>' Next ?'<p align="left" style="margin-top: -15"> </p>' ReDim $7 $ReportProgg.Value = $ReportProgg.Value+1 Next EndIf ? ?'</body>' ? ?'</html>' $nul = ReDirectOutput("") $ReportProgg.Value = 0 $ReportProgg.Caption = "Done" Run '%comspec% /c report.html' EndFunction
Suggestions? [ 27. September 2002, 14:51: Message edited by: Vig ]
|
|
Top
|
|
|
|
#70312 - 2002-09-27 09:30 PM
Re: Softwhere? - the latest update
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
VIG
I downloaded it and it appears to work "kind of". I could not get any systems or software listed. It did the scan of the computers I selected "or so it said", but then under search for software it had nothing listed or useable.
Is it possible to compile this from log files already generated? This current method using NETVIEW2 will only do NT/2000/XP systems. If you scan or readline a log/text file you can gather this information from ALL Windows systems.
Also, scanning thousands of systems remotely is not very practical "in my opinion". I really like the work you've done so far, but as I said... having the client generate the log files during logon is more practical for a large enterprise. Your current method though is great if you just want to do a "current" snapshot and the user has not logged off to run a logon script in a long time.
Is it possible to set this up maybe doing via both methods? SCAN and read from an existing Log File
Here is the code I use to get the data during logon.
code:
; SoftInventory Break on $logsrv="SERVER-X" $aStart=@ticks $outfile = "\\"+$logsrv+"\LOGS\Inventory\@wksta.log" $software = qs(getinstalledsoftware) If exist($outfile) del $outfile endif $nul = open(1, $outfile,5) $ = writeline(1,@Wksta+"*"+@FullName+"*"+@USERID+"*"+@IpAddress0+"*"+@PRODUCTTYPE+"*"+@CSD+"*"+@crlf) For each $item in $software $ = writeline(1,$item+@crlf) next $nul = close(1) $aStop=@ticks ? "Running Time is: " $aStop-$aStart Return
function GetInstalledsoftware Dim $softwarekey, $index dim $temparray[10]
$SoftwareKey = enumkey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\",$Index)
while not @error $DisplayName = readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$SoftwareKey","displayname") $DisplayVersion = readvalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$SoftwareKey","DisplayVersion") if $DisplayName if $count > ubound($temparray) redim preserve $temparray[ubound($temparray)+10] endif $temparray[$count] = $DisplayName +" "+ $DisplayVersion $count = $count + 1 endif $Index = $Index + 1 $SoftwareKey = enumkey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\",$Index) loop if $count > 0 redim preserve $temparray[$count-1] else $temparray = "" endif $getinstalledsoftware = $temparray endfunction
function qs($a) DIM $ls[32],$us[32],$sp,$L,$U,$m,$p,$i,$j,$t $ls[0]=0 $us[0]=UBOUND($a) $sp=0 While $sp >=0 $l=$ls[$sp] $u=$us[$sp] While $L < $U $p=$L+($U-$L)/2 $t=$a[$L] $A[$L]=$A[$P] $A[$P]=$t $i=$L+1 $j=$U :L1 While ($i<$j) AND $A[$L] > $A[$i] $i=$i+1 Loop While ($j>=$i) AND $A[$j] > $A[$L] $j=$j-1 Loop IF $i >= $j goto L2 ENDIF $t=$A[$i] $A[$i]=$A[$j] $A[$j]=$t $j=$j-1 $i=$i+1 Goto L1 :L2 $t=$a[$l] $a[$l]=$a[$j] $a[$j]=$t $m=$j If $m-$l <= $u - $m If $m+1 < $u $ls[$sp]=$m+1 $us[$sp]=$u $sp=$sp+1 Endif $u=$m-1 Else If $m-1 > $l $ls[$sp]=$l $us[$sp]=$m-1 $sp=$sp+1 Endif $l=$m+1 Endif Loop $sp=$sp-1 Loop $qs=$a Endfunction
|
|
Top
|
|
|
|
#70315 - 2002-10-02 10:26 AM
Re: Softwhere? - the latest update
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
NTDOC, I probably should have written some instructions on how to use the script once it's working. 1) Set the default directories. 2) Scan the computers you wish to collect the info from via the "Scan Computers" form. 3) Parse all of the log files into the access database via the "Database Management" form. All of your .log files should appear in the listbox on the left side of the form. 4) Either select "Search for software by computer" or "Search for computer by software". The necessary functions to collect this information kick off when you select the button on the menu. The progress bar at the bottom will show how far along the process is.
If you are not getting any results in step 4 then check the files in this order. 1) Check to see there are .log files in the directory where you specified the log files to be placed. 2) Check to see there is actually text within these .log files. 3) Check to see there is data in the database. There should be a table called TBL_PROGRAM in the database. Within this table there should be two columns, one for computer name and the other for program name. If this table is empty then the "Parse all logg files now" either didn't work or it was never selected. If there is information in the table then step 4 from above should work.
I intentionally designed this to only scan NT4+ systems because of the remote registry dependency (I could be wrong but I believe the remote readvalue depends on remote registry service) plus I don't have any 9X machines on my network.
As far as creating a logon script alternative, I copied the scan function out of the main script and edited it to work locally instead of remotely.
code:
$logpath = "\\server\share" Dim $programs Dim $Subkeys
$index = -1 While @error = 0 ReDim preserve $subkeys[Ubound($subkeys)+1] $index = $index+1 $subkeys[Ubound($subkeys)] = EnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",$index) Loop
For Each $key in $subkeys $Displayname = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$key","Displayname") If $Displayname <> "" ReDim preserve $programs[Ubound ($programs)+1] $programs[Ubound($programs)] = $Displayname EndIf Next $nul = ReDirectOutput ("$logpath\@WKSTA.log",1) join($programs,"~*~") $nul = ReDirectOutput("")
I tried your script and it would be possible for me to modify my script to work with your current .log format. If you look at one of the output files from my script you'll notice I put everything on one line. I did this in an attempt to make the (both scan and report) scripts work faster. Instead of writing multiple times and reading multiple times it does one for each. I don't know how much time this ended up saving if it saved any at all, I thought it was a good idea.
For what it matters I tried this on my domain a couple days ago. So far I've collected 535 .log files and after parsing them into the DB, the DB has over 14,000 records. With this many entries in the DB the Searching forms take a while to process through the information. I don't know how to make this faster than it already is. Considering it has to strip only unique strings out of an array that contains 14,000 strings I think it's still fairly fast. I'm open to suggestions.
Also, can anyone suggest a packager so I can make the setup a little less painful?
Thanks
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 874 anonymous users online.
|
|
|