This is a multi-part message in MIME format.
------=_NextPart_000_001E_01C518E0.F73DA380
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
The following script runs ok on Win2k/Xp, however, failed on NT, have =
not tested on Win9x. Can anyone give me some hints who should I write =
this to support NT/win9X.
Anyway, the script is just to query RAM, server tag, information only.
Thanks,
Frank
On Error Resume Next
Const wbemFlagReturnImmediately =3D &h10
Const wbemFlagForwardOnly =3D &h20
Const CONVERSION_FACTOR =3D 1048576
' specify the computer in the array.
arrComputers =3D Array("127.0.0.1")
For Each strComputer In arrComputers
Set objWMIService =3D GetObject("winmgmts:\\" & strComputer & =
"\root\CIMV2")
' to get computer name, model, logon user, totol memory, etc.
Set colItems =3D objWMIService.ExecQuery("SELECT * FROM =
Win32_ComputerSystem", "WQL", _
wbemFlagReturnImmediately + =
wbemFlagForwardOnly)
For Each objItem In colItems
strModel =3D objItem.Model
StrComputerName =3D objItem.Name
StrTotolPhysicalMemory =3D objItem.TotalPhysicalMemory
strUserName =3D objItem.UserName
Next
' to get the service tag,
Set objWMIService =3D GetObject("winmgmts:" _
& "{impersonationLevel=3Dimpersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSMBIOS =3D objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
strServiceTag =3D objSMBIOS.SerialNumber
Next=20
' output the value =20
WScript.Echo
WScript.Echo =
"=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"
WScript.Echo "Computer Name: " & StrComputerName
WScript.Echo "Service Tag: " & strServiceTag
WScript.Echo "Hardware Model: " & strModel
WScript.Echo "Logon User: " & strUserName
WScript.Echo "Total Physical Memory: " & Int(StrTotolPhysicalMemory =
/CONVERSION_FACTOR) & "M"
WScript.Echo =
"=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"
=20
' to get the Physical Memeory infomation
Set colItems =3D objWMIService.ExecQuery("SELECT * FROM =
Win32_PhysicalMemory", "WQL", _
wbemFlagReturnImmediately + =
wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo "Tag: " & objItem.Tag
WScript.Echo "Capacity: " & objItem.Capacity / CONVERSION_FACTOR & =
"M"
WScript.Echo "DeviceLocator: " & objItem.DeviceLocator
WScript.Echo "MemoryType: " & objItem.MemoryType
WScript.Echo "Name: " & objItem.Name
WScript.Echo "PositionInRow: " & objItem.PositionInRow
WScript.Echo "TotalWidth: " & objItem.TotalWidth
WScript.Echo "TypeDetail: " & objItem.TypeDetail
WScript.Echo
Next
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:=20
WMIDateStringToDate =3D CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & =
Mid(dtmDate,13, 2))
End Function
------=_NextPart_000_001E_01C518E0.F73DA380
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1491" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The following script runs ok on =
Win2k/Xp, however,=20
failed on NT, have not tested on Win9x. Can anyone give me some hints =
who should=20
I write this to support NT/win9X.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Anyway, the script is just to query =
RAM, server=20
tag, information only.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Frank</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>On Error Resume Next<BR>Const=20
wbemFlagReturnImmediately =3D &h10<BR>Const wbemFlagForwardOnly =3D=20
&h20<BR>Const CONVERSION_FACTOR =3D 1048576</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>' specify the computer in the=20
array.<BR>arrComputers =3D Array("127.0.0.1")<BR>For Each strComputer In =
arrComputers<BR> Set objWMIService =3D =
GetObject("winmgmts:\\"=20
& strComputer & "\root\CIMV2")<BR>' to get computer name, model, =
logon=20
user, totol memory, etc.<BR> Set colItems =3D=20
objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL",=20
_<BR> &n=
bsp; &nb=
sp; &nbs=
p; =20
wbemFlagReturnImmediately + wbemFlagForwardOnly)<BR> =
For Each=20
objItem In colItems<BR> strModel =3D=20
objItem.Model<BR> StrComputerName =3D=20
objItem.Name<BR> StrTotolPhysicalMemory =
=3D=20
objItem.TotalPhysicalMemory<BR> =
strUserName =3D=20
objItem.UserName<BR> Next</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>' to get the service tag,<BR> Set=20
objWMIService =3D GetObject("winmgmts:" _<BR> =
&=20
"{impersonationLevel=3Dimpersonate}!\\" _<BR> =
&=20
strComputer & "\root\cimv2")<BR> Set colSMBIOS =3D=20
objWMIService.ExecQuery _<BR> ("Select * from=20
Win32_SystemEnclosure")<BR> For Each objSMBIOS in=20
colSMBIOS<BR> strServiceTag =3D=20
objSMBIOS.SerialNumber<BR> Next <BR>' output the=20
value =
<BR> =20
WScript.Echo<BR> WScript.Echo=20
"=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"<BR> &n=
bsp; =20
WScript.Echo "Computer Name: " & =
StrComputerName<BR> =20
WScript.Echo "Service Tag: " & =
strServiceTag<BR> =20
WScript.Echo "Hardware Model: " & =
strModel<BR> =20
WScript.Echo "Logon User: " & =
strUserName<BR> =20
WScript.Echo "Total Physical Memory: " & =
Int(StrTotolPhysicalMemory=20
/CONVERSION_FACTOR) & "M"<BR> WScript.Echo=20
"=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"<BR> &n=
bsp; <BR>'=20
to get the Physical Memeory infomation<BR> Set colItems =3D=20
objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL",=20
_<BR> &n=
bsp; &nb=
sp; &nbs=
p; =20
wbemFlagReturnImmediately + wbemFlagForwardOnly)<BR> For Each =
objItem In=20
colItems<BR> WScript.Echo "Tag: " &=20
objItem.Tag<BR> WScript.Echo "Capacity: " &=20
objItem.Capacity / CONVERSION_FACTOR & =
"M"<BR> =20
WScript.Echo "DeviceLocator: " &=20
objItem.DeviceLocator<BR> WScript.Echo =
"MemoryType: "=20
& objItem.MemoryType<BR> WScript.Echo "Name: =
" &=20
objItem.Name<BR> WScript.Echo "PositionInRow: " =
&=20
objItem.PositionInRow<BR> WScript.Echo =
"TotalWidth: "=20
& objItem.TotalWidth<BR> WScript.Echo =
"TypeDetail: "=20
& objItem.TypeDetail<BR> =20
WScript.Echo<BR> Next<BR>Next</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Function=20
WMIDateStringToDate(dtmDate)<BR>WScript.Echo dtm: =
<BR> WMIDateStringToDate=20
=3D CDate(Mid(dtmDate, 5, 2) & "/" & _<BR> Mid(dtmDate, 7, =
2) &=20
"/" & Left(dtmDate, 4) _<BR> & " " & Mid (dtmDate, 9, =
2) &=20
":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))<BR>End =
Function</FONT></DIV></BODY></HTML>
------=_NextPart_000_001E_01C518E0.F73DA380--