#20078 - 2002-04-18 12:03 AM
Re: For all the Gurus...
|
BrianTX
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
|
|
|
|
#20080 - 2002-04-18 01:50 AM
Re: For all the Gurus...
|
Howard Bullock
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.
|
|
Top
|
|
|
|
#20081 - 2002-04-18 02:03 AM
Re: For all the Gurus...
|
Chris S.
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
|
|
|
|
#20085 - 2002-04-18 02:56 AM
Re: For all the Gurus...
|
Jake
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
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.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
You're right, Jake, but I never claimed to be a guroo. (But, does your's sort the list alphabetically. I thought not. )
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
|
|
|
|
#20090 - 2002-04-23 11:25 PM
Re: For all the Gurus...
|
Car guy
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|