Page 1 of 1 1
Topic Options
#20077 - 2002-04-17 11:55 PM For all the Gurus...
badboii Offline
Fresh Scripter

Registered: 2002-03-07
Posts: 32
Loc: Seattle, WA
Okay I've been playing with Kix for the past few months now and I love it - especially with the help from this bulletin board..

Okay this is what I want to do (with kix of course) and I'm open to any suggestions.

When a user logs on I want the script to grab:
*cpu
*mem
*hd space
*installed programs
*system id (I'll put in this unique id)

I'm thinking that the next part will require a COM

I want it to take that information and update it in an access database by the system id. Basically update all the tables in the database under the system id.

Eventually I want to have an asp page that will be searchable by user name/computer name/system id and show all the up to date information.

Hmmm any takers?
[Roll Eyes] brian_zamora@hotmail.com
_________________________
========================== Brian Zamora Computer Technician brian_zamora@hotmail.com ==========================

Top
#20078 - 2002-04-18 12:03 AM Re: For all the Gurus...
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
It's easy enough to pull the information... all that stuff is accessible directly through either KIX functions or in the registry... the big thing would be to allow it to create/update a database... this is something that might be useful to a lot of people rather than spending large amounts of money on software that does the same thing (for us cheap ones).

I would guess that the best way would be to get all the info via kix, then write it to a file based on the computer name. Then that file could be copied to a server somewhere with a security code passed to the script. You could have a script on that server that ran every hour and compiled the new computerid.txt files into a database... I could probably get there from here.. except for the database part..

Anyone?

Brian

Top
#20079 - 2002-04-18 12:30 AM Re: For all the Gurus...
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
This would be cool!! But we already use a program for this called Audit Wizard.

I will be wathching this post to see if it takes off and input any help I can.

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#20080 - 2002-04-18 01:50 AM Re: For all the Gurus...
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Do you have a SQL database available? If so, my recommendation would be to have the client write an INI file to a central server and have a Perl program pump the data into the SQL database. This could be an Access database as well I guess. the only reason I suggest Perl is that I do that all the time and might be able to supply the compiled program.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#20081 - 2002-04-18 02:03 AM Re: For all the Gurus...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I have just the code for you. This is entirely ripped off from others on this board and includes a UDF from Scriptlogic. Cut and paste this code and run it. Pretty cool stuff.

code:
BREAK ON CLS
REDIRECTOUTPUT("%WINDIR%\Test.txt",1)
? "System Name = "WMIQuery("CSName","Win32_OperatingSystem")
? "OS Name = "WMIQuery("Caption","Win32_OperatingSystem")
? "Manufacturer = "WMIQuery("Manufacturer","Win32_OperatingSystem")
? "OS Version Number = "WMIQuery("Version","Win32_OperatingSystem")
? "OS Build Number = "WMIQuery("BuildNumber","Win32_OperatingSystem")
? "OS Build Type = "WMIQuery("BuildType","Win32_OperatingSystem")
? "Language = "WMIQuery("OSLanguage","Win32_OperatingSystem")
? "Service Pack = "WMIQuery("CSDVersion","Win32_OperatingSystem")
? "Boot Device = "WMIQuery("BootDevice","Win32_OperatingSystem")
? "System Device = "WMIQuery("SystemDevice","Win32_OperatingSystem")
? "Windows Directory = "WMIQuery("WindowsDirectory","Win32_OperatingSystem")
? "System Directory = "WMIQuery("SystemDirectory","Win32_OperatingSystem")
? "Install Date = "WMIQuery("InstallDate","Win32_OperatingSystem")
? "Last Boot Time = "WMIQuery("LastBootupTime","Win32_OperatingSystem")
? "Registered User = "WMIQuery("RegisteredUser","Win32_OperatingSystem")
? "Registered Organization = "WMIQuery("Organization","Win32_OperatingSystem")
? "OS Serial Number = "WMIQuery("SerialNumber","Win32_OperatingSystem")
? "System Manufacturer is = "WMIQuery("Manufacturer","Win32_ComputerSystem")
? "System Model is = "WMIQuery("Model","Win32_ComputerSystem")
? "System Serial Number is = "WMIQuery("SerialNumber","Win32_BIOS")
? "System BIOS Version is = "WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")
? "System BIOS Date is = "WMIQuery("Version","Win32_BIOS")
? "CPU Manufacturer: = "WMIQuery("manufacturer","Win32_Processor")
? "Description: = "WMIQuery("description","Win32_Processor")
? "CPU Speed is = "WMIQuery("CurrentClockSpeed","Win32_Processor") " Mhz"
? "Maximum Clock Speed = "WMIQuery("maxclockspeed","Win32_Processor") " Mhz"
? "L2 Cache Size: = "WMIQuery("l2cachesize","Win32_Processor")
? "L2 Cache Speed: = "WMIQuery("l2cachespeed","Win32_Processor")
? "Family: = "WMIQuery("family","Win32_Processor")
? "Level: = "WMIQuery("level","Win32_Processor")
? "Stepping: = "WMIQuery("stepping","Win32_Processor")
? "Device ID: = "WMIQuery("deviceid","Win32_Processor")
? "Unique ID: = "WMIQuery("uniqueid","Win32_Processor")
? "System Memory = "val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 " MB"
for each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
? "Dimm Size = "val($dimm) / 1048576 " MB"
next
? "Disk Name/s = "WMIQuery("name","Win32_LogicalDisk")
? "Volume Name = "WMIQuery("volumename","Win32_LogicalDisk")" MB"
? "Size = "WMIQuery("size","Win32_LogicalDisk") " MB"
? "File System = "WMIQuery("filesystem","Win32_LogicalDisk")
? "Free Space = "WMIQuery("freespace","Win32_LogicalDisk")" MB"
? "Video Card is = "WMIQuery("Description","Win32_VideoController")
? "Video Res is = "WMIQuery("VideoModeDescription","Win32_VideoController")
? "Modem is = "WMIQuery("Description","Win32_POTSModem")
for each $ptr in Split(WMIQuery("Name","Win32_printer"),"|")
? "Connected Printer is = "$ptr
next
for each $nic in Split(WMIQuery("ProductName","Win32_NetworkAdapter"),"|")
if instr($nic,"miniport")=0 and instr($nic,"RAS")=0 and instr($nic,"Parallel")=0
? "Network Card is = "$nic
endif
next

??'The following applications are installed on this computer:'
$InstalledSoftwareArray=GetSoftwareList(1)
for each $element in $InstalledSoftwareArray
?$element
next

function GetSoftwareList(OPTIONAL $Sort)
; Author: ScriptLogic Corporation
; Last revised: 16-nov-2001
; Optional parameter: sort
; if 0 (or not supplied), no sorting of list is done.
; if 1, results are sorted alphabetically, ascending order
; Note: If sorting is requested, this function then has a
; dependency on the Asort( ) UDF.
dim $ArrayIndex, $EnumIndex, $Component, $DN, $RegKey, $SwArray[200]
$RegKey='HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall'
$EnumIndex=0
$ArrayIndex=0
:gisloop
$Component=EnumKey($RegKey, $EnumIndex)
if not @Error
;if not (len($Component)=7 and left($Component,1)='Q')
; above line excludes hotfixes from listing
if not (0+readvalue($RegKey+'\'+$Component,'SystemComponent'))
$DN=readvalue($RegKey+'\'+$Component,'DisplayName')
if $DN
$SwArray[$ArrayIndex]=$DN
$ArrayIndex=$ArrayIndex+1
endif
endif
$EnumIndex=$EnumIndex+1
goto gisloop
;endif
endif
redim preserve $SwArray[$ArrayIndex]
if $Sort
$GetSoftwareList=Asort($SwArray)
else
$GetSoftwareList=$SwArray
endif
endfunction

function ASort($array, OPTIONAL $order)
; sort order: 0 = ascending, 1 = decending
dim $index, $x, $y, $tmp, $changed
$Asort=$array
$order=0+$order
do
$changed=0
for $index = 0 to ubound($asort)-1
$x=$asort[$index]
$y=$asort[$index+1]
if ($x > $y and 1-$order) or ($x < $y and $order)
$tmp=$x
$asort[$index]=$y
$asort[$index+1]=$tmp
$changed=1
endif
next
until $changed=0
endfunction


FUNCTION WMIQuery($what,$where,)
dim $strQuery, $objEnumerator, $value
$strQuery = "Select $what From $where"
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//@WKSTA")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 and $objInstance <> ""
$=execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
EndIf
Next
$WMIQuery=left($WMIQuery,len($WMIQuery)-1)
exit @error
ENDFUNCTION
$computer = @wksta
? WMIQuery2("Services on","Win32_Service")
? WMIQuery2("Processes on","Win32_Process")
FUNCTION WMIQuery2($what,$where,)
$wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $computer + "/root/cimv2")
$list = ""
$objs = $wmi.instancesof($where)
for each $obj in $objs
$list = $list + $obj.description + chr(13) + chr(10)
next
$list=Left($list, Len($list))
?$what +" "+ $computer + chr(13) + chr(10) + $list
ENDFUNCTION

run 'notepad.exe "%windir%\test.txt"'

EDIT: Updated script to "rem" out mal-functioning code. Will now return all non-OS component installed software, including hotfixes.

[ 18 April 2002, 15:49: Message edited by: Chris S. ]

Top
#20082 - 2002-04-18 02:22 AM Re: For all the Gurus...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Chris,

Just an FYI, the script for the installed software does not function properly. It does not retrieve the complete list of installed applications. I have 170+ installed applications and the code stops at the "P's" for installed software.

Also note that the WMI code requires KiXtart v4.x as well as the target machine having WMI installed.

MCA has a script on his website to perform inventory tasks as well.

If I get time I'll try to clean up the code from ScriptLogic so that it does retrieve all the software. In the meantime, please checkout MCA's website.

[ 18 April 2002, 02:23: Message edited by: NTDOC ]

Top
#20083 - 2002-04-18 02:32 AM Re: For all the Gurus...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Hmmm. The $SWArray variable, as scripted, should return 200 results from the "Uninstall" section of your registry. You could up the $SWArray and see how that runs. There is probably a way to enum the "Uninstall" section of the registry so you get the entire results, but I haven't played around with the code yet.
Top
#20084 - 2002-04-18 02:39 AM Re: For all the Gurus...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You're right. Mine stopped in the "P's" as well and it seemed to miss some things in between. I'll look at it too.
Top
#20085 - 2002-04-18 02:56 AM Re: For all the Gurus...
Jake Offline
Fresh Scripter

Registered: 2001-11-14
Posts: 26
This is what I use to pull software information. Tested on NT and Kix 3.63. May be too simple for the gurus [Wink]
code:
 BREAK ON
CLS
$wsinfofile = %TEMP% + "\" + @wksta + ".ini"
DEL $wsinfofile
$rc = WriteProfileString("$WSInfoFile","WsInfo","WsName","@WkSta")
$rc = WriteProfileString("$WSInfoFile","WsInfo","User Name","@FullName")
$rc = WriteProfileString("$WSInfoFile","WsInfo","Date","@month @mdayno @year")

$rootkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
GOSUB GetInstallSoftware
$rootkey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
GOSUB GetInstallSoftware
RETURN

;---------------------------------
:GetInstallSoftware
;---------------------------------
$index = 0
$num = 0
$key = EnumKey($rootkey, $index)
WHILE @error = 0
$value = ReadValue($rootkey + $key, "DisplayName")
$uninstall = ReadValue($rootkey + $key, "UninstallString")
IF $value AND $uninstall <> "" ;include $uninstall if you just want to see software that shows up in the add/remove in the control panel. Exclude it if you want all software.
$num = $num + 1
$rc = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Num", "$Value")
ENDIF
;$Num = $Num + 1
$index = $index + 1
$key = EnumKey($rootkey, $index)
LOOP
RETURN


Top
#20086 - 2002-04-18 03:11 AM Re: For all the Gurus...
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You're right, Jake, but I never claimed to be a guroo. [Wink] (But, does your's sort the list alphabetically. I thought not. [Wink] )

I found the problem. The following line causes the function to stop running as soon as it finds the first "hotfix" in the uninstall key:

code:
if not (len($Component)=7 and left($Component,1)='Q')

"Rem" out that line AND the corresponding "endif" statement and you'll get all of the software.

[ 18 April 2002, 03:12: Message edited by: Chris S. ]

Top
#20087 - 2002-04-18 08:08 AM Re: For all the Gurus...
badboii Offline
Fresh Scripter

Registered: 2002-03-07
Posts: 32
Loc: Seattle, WA
Whoa Chris - I haven't tried that code yet but it looks tasty [Wink]

I think I might take that suggestion on looking at MCA site and using Perl to input that stuff into a SQL/ACCESS database...if I get anywhere you know this will be the first place I post it!

Thanks alot guys - hey if anyone has any more ideas please keep them coming....
brian_zamora@hotmail.com [Big Grin]
_________________________
========================== Brian Zamora Computer Technician brian_zamora@hotmail.com ==========================

Top
#20088 - 2002-04-18 08:50 AM Re: For all the Gurus...
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Here is the original thread where "most" of this code came from for those interested in a little more information on the topic.

TotalMem( $Systemname ) - Determine amount of memory installed using WMI

And here is the Software inventory routine that Fabian did back in Dec 2000 (his code needs some rework as well, but it went along the same lines of sorting the output. The ScriptLogic method does appear to work well though.

Inventory Script (Software/Network/User Info)

MCA's links to similar topics
Inventory tool

Radimus has a good long script for inventory as well.

Inventory Script for all OS's!

Top
#20089 - 2002-04-19 12:08 AM Re: For all the Gurus...
Breaker Offline
Hey THIS is FUN
*****

Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
If you look in this thread you'll see (2nd post!) the script I use to collect all kinds of inventory info and write it to an Access 97 database.

The script uses Kix 4.02, and the client requirements are to have ADO and WMI runtimes available on all machines that will be audited. These can be downloaded from Microsoft's web site (I won't include a link now because it'll probably change before you get to look at it... small whinge at Gates and co. [Wink] ) so they're easy enough to get hold of.

I used Access 97 since that's what the overwhelming majority of our clients have installed, and even with the ADO runtimes, they weren't happy about connecting to a Jet 4.0 database.

I had thought about converting to SQL server, but at the moment the size of the organisation and the complexity of the data just doesn't warrant it. Anyway, I hope this helps.

[ 18 April 2002, 12:11: Message edited by: Breaker ]
_________________________
================================================
Breaker


Top
#20090 - 2002-04-23 11:25 PM Re: For all the Gurus...
Car guy Offline
Lurker

Registered: 2002-02-11
Posts: 4
Loc: Beaverton, Oregon
I have a script that collects this infomration, - not disssimilar from what's been posted here. Output goes to a .CSV on the LAN. CPU and HDD info are done by freeware programs, although I see v4.1 of KIX remedies this need.

For installed software capture I simply enumerate the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" key. To capture miscallenous stuff that might not use the Windows Uninstaller I query the \Startup folder and \Run registry keys, for my uses this is sufficient.

My fellow Admins can get to this .CSV by an Intranet page. Specifically the link calls a .BAT which copies the live file to a local temp file and they then open the file locally. This way a user can log in while we are looking at the most recent data and not have to worry about an open file error preventing an update. (.BAT contents follow).

code:
@echo off
if exist %temp%\~tfcauditpvd.csv del %temp%\~tfcauditpvd.csv
copy \\<servername>\shared\pc-info\tfcaudit.csv %temp%\~tfcauditpvd.csv
explorer %temp%\~tfcauditpvd.csv
cls
:end

Kind of along these lines...
Something I've recently started doing is using NBTSTAT (assuming a WinTel environemnt) and KiXtart to get MAC addr/IP/MachineName/USERID info. Somtimes I get an error with a MAC address as the reference and I need to nail it down to a PC or user quickly.

[ 24 April 2002, 22:24: Message edited by: Car guy ]
_________________________
Keyboard error - press F1 to resume Dave Lum - dlum@tfc.textron.com Sr. Network Specialist, TFC-Textron 503.675.5510 / 800-704-5208(fax)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 384 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.033 seconds in which 0.013 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org