#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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|