#149745 - 2005-10-12 11:26 AM
Hardware inventory script malfunction
|
yellowdog
Starting to like KiXtart
Registered: 2005-06-14
Posts: 102
|
Hi,
I downloaded the script script_149.kix(Add Computer Info to Registry) from the AdminScriptEditor.com web site in order to extract S/N, Model, construcror .... This script is working fine with windows 2000 and 2003 operating system. But with NT4 OS (I have installed WMINT4.EXE on NT4 machines)the S/N, model and manufacturer are blanked in the report and that's the main information I want to extract fom computers.
Is there any reason that the report is blank or does it exist an other script that could solve the problem.
Thanks
Here is the source of the script. ;=================================== ;**** Last Modified on 8/6/02 at 11:58:59 AM by WVHETRICK **** ;===================================
Break on ; the default skip is 6 $Skip = 6 $Count = $skip $Count2 = 1
$Answer = MessageBox("Do you want to manually update one at a time?","How do you want to update?",4) If $Answer = 6 $RC = single() Exit EndIf
For Each $machine in netview("@LDOMAIN")
? "$MACHINE"
$Count = $Count + 1 $computer = $machine $Comp = "" $Model= "" $Sernum ="" $Cpu = "" $Mem = "" $Computer2 = "\\"+$computer ReDim $MEM2,$DIMM
;Shell ''%comspec% /c ping -n 2 "$Machine" | find /i "ttl" >nul 2>nul'' ;If NOT @ERROR
$VERSION = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION","CURRENTVERSION") $WMICORE = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WBEM","Build") If $VERSION = "4.0" AND @ERROR <> 0 AND $WMICORE <> "1085.0005" "Updating WMI" $RC = UpdateProg(" c:\wmint4.exe /s","$computer") EndIf
If KeyExist($Computer2 + "\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions") $REG = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE","SerialNumber") If $REG = "" $Sernum = Rtrim(WMIQuery("SerialNumber","Win32_BIOS")) $SERNUM = CHECKREG($SERNUM,"SerialNumber") $Comp = Rtrim(WMIQuery("Manufacturer","Win32_ComputerSystem")) $Comp = CHECKREG($COMP,"MANUFACTURER") $Model = Rtrim(WMIQuery("Model","Win32_ComputerSystem")) $Model = CHECKREG($MODEL,"MODEL") $CPU = Rtrim(WMIQuery("CurrentClockSpeed","Win32_Processor")) $CPU = checkREG($CPU,"CurrentClockSpeed") $Mem = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 $MEM = CHECKREG($MEM,"TotalPhysicalMemory") $smbios = Rtrim(WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")) $Smbiosdate = Rtrim(WMIQuery("Version","Win32_BIOS")) $Modem = Rtrim(WMIQuery("Description","Win32_POTSModem")) $Mem2 = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 For Each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|") $MEM2 = "" + $MEM2 + "|" + Ucase(Val($dimm) / 1048576) Next $x = loginfo("c:\COMINFO.txt","@DATE @TIME,$count,$Machine,$Comp,$Model,$Sernum,$Cpu Mhz,$Mem MB,$MEM2 MB,$SMBIOS,$SMBIOSDATE,$MODEM") $count2 = $count2 + 1 "....DONE at @TIME" EndIf EndIf ;EndIf
ut
Next
Exit 1
Function mapdrive($drive, $unc, optional $persistence) Dim $mount,$subkey, $regvalue, $retcode, $errorcode If NOT VarType($persistence) $persistence=0 EndIf If $persistence $persistence=1 EndIf ; If @INWIN=2 ; $persistence=0 ; EndIf $drive=Ucase($drive) $mount=$drive+'':'' $mapdrive=0 ; check for a valid drive letter If $drive>''C'' AND $drive<''Z'' ; check for incorrent persistent connections $subkey=$HKCU+''\Network\''+$drive If KeyExist($subkey) $regvalue=Lcase(ReadValue($subkey,''RemotePath'')) If $regvalue<>Lcase(Trim($unc)) OR $persistence=0 Use $mount /delete /persistent $retcode=DelKey($subkey) EndIf EndIf ; check if the UNC path actually exists If Exist($unc) ; delete an already existing mount If Exist($mount+''\nul'') If $VERBOSE $retcode=displaytext(''Deleting existing drive mapping for drive ''+$mount) EndIf Use $mount /delete /persistent $retcode=err(''Cannot delete existing drive mapping for drive ''+$mount) EndIf ; map the drive to the UNC path If NOT Exist($mount+''\nul'') If @INWIN=2 AND InStr($unc,''\\''+@WKSTA+''\'') ;Windows 9x cannot map to its own shares Else $retcode=displaytext(''Mounting drive letter ''+$mount+'' to ''+$unc) If $persistence=1 Use $mount $unc /persistent $errorcode=@ERROR Else Use $mount $unc $errorcode=@ERROR EndIf EndIf ; display some important error codes If $errorcode Select Case $errorcode=85 ; drive is already mapped $retcode=warning(''Drive letter ''+$mount+'' is already mounted to ''+$unc) Case $errorcode=1202 ; error is generated under Win9x if persistent connection is already listed in registry $retcode=warning(''Drive letter ''+$mount+'' is already mounted persistently to ''+$unc) Case $errorcode=2250 $retcode=warning(''Drive letter ''+$mount+'' is already mounted to ''+$unc) Case 1 $retcode=err(''Cannot mount drive letter ''+$mount+'' to ''+$unc) EndSelect EndIf Else $retcode=warning(''Drive letter ''+$mount+'' is already mounted'') EndIf Else $retcode=warning(''Drive share ''+$unc+'' is not available'') EndIf Else $retcode=warning(Ucase($drive)+'':\ is an invalid drive mapping'') EndIf $mapdrive=@error EndFunction
Function UpdateProg($Command2,$Computer) Use J: /DELETE $RC = MAPDRIVE("J","\\$COMPUTER\C$") If @ERROR = 0 Copy "C:\WMINT4.EXE" "J:" $runner = "c:\SC.EXE \\" + $Computer + " start Schedule " Shell $runner $filetime = @TIME $MINUUT = Val(SubStr($filetime,4,2)) $UUR = Val(SubStr($filetime,1,2)) If $Minuut > 44 $Uur = $Uur + 1 $Minuut = $Minuut - 45 Else $Minuut = $Minuut + 15 EndIf $FILETIME = "$UUR:$MINUUT:00" $Command = "AT \\" + $Computer + " " Shell $command + $FILETIME + $COMMAND2 Use J: /DELETE Else "FILE NOT COPIED " EndIf
EndFunction
Function Single()
;For single machines make sure you rem out the For Each AND unrem the Six below. ? "Machine name? " Gets $machine While $machine <> "Exit"
$computer = $machine $Comp = "" $Model= "" $Sernum ="" $Cpu = "" $Mem = "" $Computer2 = "\\"+$computer
$VERSION = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION","CURRENTVERSION") $WMICORE = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WBEM","Build") If $VERSION = "4.0" AND @ERROR <> 0 AND $WMICORE <> "1085.0005" "Updating WMI" $RC = UpdateProg(" c:\wmint4.exe /s","$computer") EndIf Shell '%comspec% /c ping -n 2 "$Machine" | find /i "ttl" >nul 2>nul' If NOT @ERROR ReDim $MEM2,$DIMM "$Count, " $Sernum = Rtrim(WMIQuery("SerialNumber","Win32_BIOS")) $SERNUM = CHECKREG($SERNUM,"SerialNumber") "A, " $Comp = Rtrim(WMIQuery("Manufacturer","Win32_ComputerSystem")) $Comp = CHECKREG($COMP,"MANUFACTURER") "B, " $Model = Rtrim(WMIQuery("Model","Win32_ComputerSystem")) $Model = CHECKREG($MODEL,"MODEL") "C, " $CPU = Rtrim(WMIQuery("CurrentClockSpeed","Win32_Processor")) $CPU = checkREG($CPU,"CurrentClockSpeed") "D, " $Mem = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 $MEM = CHECKREG($MEM,"TotalPhysicalMemory") "E, " $smbios = Rtrim(WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")) "F, " $Smbiosdate = Rtrim(WMIQuery("Version","Win32_BIOS")) "G, " $Modem = Rtrim(WMIQuery("Description","Win32_POTSModem")) "H, " $Mem2 = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 For Each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|") $MEM2 = "" + $MEM2 + "|" + Ucase(Val($dimm) / 1048576) Next "End." $x = loginfo("c:\COMINFO.txt","@DATE @TIME,$count,$Machine,$Comp,$Model,$Sernum,$Cpu Mhz,$Mem MB,$MEM2 MB,$SMBIOS,$SMBIOSDATE,$MODEM") Else ? "Cannot find Computer" EndIf ? "Machine name? " Gets $machine Loop Exit
EndFunction ;Used to make login script log files. ;Example LogInfo("\\server\log$\VERSION.LOG","@DATE @TIME,@WKSTA,@USERID,$Macver,$regver,$engver") Function LOGINFO($FILE,$STRING) $junk = ReDirectOutput($file) $string ? $junk = ReDirectOutput("") EndFunction Function CHECKREG($VALUE,$WHERE) $REG = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE") If $value = " " OR Len($Value) = 0 $Checkreg = $reg Else If NOT KeyExist($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE") $ReturnCode = AddKey($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE") EndIf $X = WriteValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE","$value","REG_SZ") $CHECKREG = $VALUE EndIf
Return EndFunction
Function WMIQuery($what,$where,) Dim $strQuery, $objEnumerator, $value $strQuery = "Select $what From $where" $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer") If VarType($systemSet) <> 9 AND @error <> 0 Exit(@error) EndIf $objEnumerator = $SystemSet.ExecQuery($strQuery) For Each $objInstance in $objEnumerator ;If @Error = 0 AND $objInstance <> "" $junk=Execute("$$value = $$objInstance.$what") $WMIQuery="$value"+"|"+"$WMIQuery" ;EndIf Next $WMIQuery=Left($WMIQuery,Len($WMIQuery)-1) $Systemset = nothing Exit @error EndFunction
Function netview(optional $domain) Dim $array[255] Dim $ReDim $ReDim = 255 Dim $i $i = 0 Dim $j $j = 0 Dim $tempfile $tempfile = "%temp%\netview2.tmp" If $domain $domain = "/domain:$domain" EndIf If Exist("$tempfile") Del "$tempfile" EndIf Shell '%comspec% /c net view $domain >"$tempfile"' If @error = 0 If Open(10,$tempfile) = 0 For $j = 1 to $Skip $line = ReadLine(10) ; skip headings Next While @error = 0 $array[$i] = Rtrim(SubStr($line,3,InStr($line," ")-1)) $i=$i+1 If $i = $ReDim $ReDim=$ReDim*2 ReDim preserve $array[$ReDim] EndIf $line = ReadLine(10) Loop $=Close(10) Del "$tempfile" If $i ReDim preserve $array[$i-4] $netview = $array Exit @error EndIf EndIf EndIf $netview = 0 Exit @error EndFunction
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|