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
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
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
MartMart KiX Supporter
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Some questions:
-1 Are these all the same systems? Some manufacturers do not use these fields so it gives a blank value. -2 You say WMI is installed, is the service also started? -3 When you install a NT4 machine with 2K or even XP does it return something then or are the fields still blank?
BTW: A small tip, please use the code tags when posting code so the formatting gets preserved and its more readable.
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11634
Loc: Space
My guess without testing it is that WMI on NT4 does not support the information you're trying to return.
Just because you have WMI installed does not mean the OS supports the call. There are WMI calls that are specific to every OS. i.e. There are many calls in 2003 that NT/2000/XP do not understand, there are calls for XP that NT/2000 do not understand.
I'm not saying that NT4 does not, but you would need to try and track down and run some of your own WMI test scripts, and/or read some WMI documentation to see if the call is supported on NT4 to know for sure.
Hi, 1-we get IBM and DELL machines in our park 2-the WMI service is installed and started 3-when I install a W2K OS on a former machine where NT4 was installed, the information about S/N, Model and manufacturer are fairly extracted (it's not blanked). Are the NT4 WMI object different from W2K, in that case what are the variable names to extract.
MartMart KiX Supporter
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Changing the names of the values to be retrieved could work if the OS supports it and you should know the ones to use. I do not know the names to use, this is something that can probably be found at Microsoft.
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11634
Loc: Space
Try running this code directly while logged onto the NT4 Computer in question. According to the WMI docs it should support it as long as the Mfg filled it in.