LotusScript/VBScript with WMI getting errors on some machines

Here is the script:Sub Postopen(Source As Notesuidocument)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim vWMI_OperatingSystem As Variant

Dim vWMI_ComputerSystem As Variant

Dim vWMI_Processor As Variant

Dim vWMI_Reg As Variant

Dim vWMI_Disk As Variant

Dim vWMI_LDisk As Variant

Dim s As String

Dim C As String

C = "."



Dim l As String

Dim g As Integer

Dim gr As String	

Dim jr As String



Set uidoc = ws.CurrentDocument

If uidoc.IsNewDoc Then

	Set CompSys = GetObject ( "winmgmts:{impersonationLevel=impersonate}" ).InstancesOf( "Win32_BIOS" )

	Set vWMI_ComputerSystem = GetObject ( "winmgmts:{impersonationLevel=impersonate}" ).InstancesOf ( "Win32_ComputerSystem" )

	Set vWMI_OperatingSystem = GetObject ( "winmgmts:{impersonationLevel=impersonate}" ).InstancesOf ( "Win32_OperatingSystem" )

	Set vWMI_Processor = GetObject ( "winmgmts:{impersonationLevel=impersonate}" ).InstancesOf ( "Win32_Processor" )

	Set vWMI_Reg = GetObject ( "winmgmts:{impersonationLevel=impersonate}!\\" & C & "\root\default:StdRegProv" )

	Set vWMI_Disk = GetObject ( "winmgmts:{impersonationLevel=impersonate}" ).InstancesOf ( "Win32_DiskDrive" )

	Set vWMI_Ldisk = GetObject ( "winmgmts:").InstancesOf ("Win32_LogicalDisk")

	

	

	

	Forall comp In CompSys

		s = comp.SerialNumber

		z = comp.Manufacturer

		Call uidoc.FieldSetText("make",z)

		Call uidoc.FieldSetText("SerialNumber",s)

		

	End Forall

	Forall comp In vWMI_ComputerSystem

		t = comp.SystemType

		rp = Round(comp.TotalPhysicalMemory/1048576, 0)

		r = Cstr(rp)

		p = comp.Model

		q = comp.UserName

		Call uidoc.FieldSetText("os1", t)

		Call uidoc.FieldSetText("total",r)

		Call uidoc.FieldSetText("model",p)

		Call uidoc.FieldSetText("username",q)

		

	End Forall

	

	strKeyPath = "Hardware\DESCRIPTION\System\CentralProcessor\0"

	strEntryName = "Identifier"

	vWMI_Reg.GetStringValue HKEY_LOCAL_MACHINE,StrKeyPath,StrEntryName,strValue

	l = strValue

	Call uidoc.FieldSetText("pro",l)

	

	Forall comp In vWMI_OperatingSystem

		z = comp.Caption

		a = comp.CSDVersion

		b = comp.CSName

		Call uidoc.FieldSetText("level",z)

		Call uidoc.FieldSetText("sp",a)

		Call uidoc.FieldSetText("sc",b)

		

	End Forall

	Forall comp In  vWMI_Processor

		k = comp.Manufacturer

		x = Cstr(comp.MaxClockSpeed)

		Call uidoc.FieldSetText("processor",k)

		Call uidoc.FieldSetText("mcs",x)		

	End Forall

	

	Forall comp In  vWMI_Disk

		j = Round(comp.Size/2^30, 1)

		jr = Cstr(j)		

		Call uidoc.FieldSetText("size",jr)		

	End Forall

	

	Forall comp In vWMI_LDisk

		m = comp.Name

		If m = "C:" Then

			g = comp.FreeSpace/1048576

			gr = Cstr(g)

		End If

		Call uidoc.FieldSetText("space",gr)

	End Forall

Else

	Set doc = uidoc.Document

End If

End Sub

Basically, it is a Lotus/VBScript that pulls information from the WMI to post it to a form. The problem I “appear” to be having is that if it is run on certain machines, it captures too much information in the total total dsik space and overrruns that alloted amount of space for the variable. I thought it was unique to my home machine because I had a 120gig drive and the other folsk working with me were in office with 10gig drives. I went into office and ran it on my 40gig laptop and it was ok. BUT the guyg next to me ran it on his 40gig desktop and he gets the error that appears to overrrun the variable. ???

Any suggestions or assitance apprecited. Borrow the code if you wish just kindly let me know you did.

Thanks

G

Subject: LotusScript/VBScript with WMI getting errors on some machines

Dim G as Long rather than Integer and see if that helps.

Subject: RE: LotusScript/VBScript with WMI getting errors on some machines

Nope. Still the same. I’m sure the error is being caused by overflow but I’m not sure how to do the math without putting it into a variable to do it on.

Thanks

G

Subject: RE: LotusScript/VBScript with WMI getting errors on some machines

got it. lol.

did ‘resume on error next’.

works and no error.

G