WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Example Code to Pull the Machine's Manufacturer, Model and Serial Number using WMI

Keywords:   Pull the Machine's Manufacturer, Model and Serial Number  WMI

Here is some code to pull the machine's Manufacturer, Model and Serial from WMI.
#DefineFunction GetWMIInfo()
	IntControl(73, 2,0,0,0)
	Locator = ObjectOpen("WbemScripting.SWbemLocator")
	Service = Locator.ConnectServer()
	Security = Service.Security_     
	Security.ImpersonationLevel = 3
	Class = "Win32_ComputerSystemProduct"
	Instance = Service.InstancesOf(Class)
	Enum = ObjectCollectionOpen(Instance)
	While 1
		Obj = ObjectCollectionNext(Enum)
		If Obj == 0 Then Break
		man=Obj.Vendor
		model=Obj.Name
		serial=Obj.IdentifyingNumber
	EndWhile
	
	ObjectCollectionClose(Enum)
	ObjectClose(Instance)
	ObjectClose(Security)
	ObjectClose(Service)
	ObjectClose(Locator)
	data=StrCat(man,@TAB,model,@TAB,serial)
	Return(data)
	
	:WBERRORHANDLER
	Error=LastError()
	Terminate(error!=3246,"Error %error%",StrCat(wberrorhandlerline,@CRLF,IntControl(34,error,0,0,0)))
	%wberrorhandlerassignment%="Not Found"
	IntControl(73, 2,0,0,0)
	Return

#EndFunction


datax=GetWmiInfo()
AskItemlist("",datax,@TAB,@UNSORTED,@SINGLE)


Article ID:   W15787
File Created: 2003:05:13:11:30:06
Last Updated: 2003:05:13:11:30:06