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

System Information

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

Sample Code to Collect Information about Workstations Including MAC Address, BIOS version, Screen Resolution...

Keywords: 	  MAC Address BIOS version Screen Resolution

My company is currently putting together an inventory of all our workstations. This was going to entail a tech going to each station and taking notes on everything from serial numbers to configuration info.

I can't poll for Serial Numbers on the Mice; However, I did put together this snazzy script to make our lives easier.

When run, the script puts up a form, for the Tech to put info in manually, and fills in all the info I've been able to get Winbatch to wrangle automatically. (Everything from MAC address and UName to BIOS version and Screen Resolution)

The info (manually and automatically gathered) is then appended to a delimited text file which you can then suck into almost any database.

We've been using it for a few months now to great success.

It's commented well enough that you should be able to dissect and leech parts of it for other applications, or adapt it for your own organization.

---Kris T.

;Name: InfoCollect.wbt
;Author: Kris Truzzi
;Last Update: 10/14/99


:LOADVAR
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Set the location and name of the file to post info to ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
	DBFILE="\\MYSERVER\PUBLIC\collect.txt"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Get Windows Version Info ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	minorver = WinVersion(@MINOR)
	majorver = WinVersion(@MAJOR)

;;;;;;;;;;;;;;;;;;;;;;
; Determine CPU Type ;
;;;;;;;;;;;;;;;;;;;;;;
	wcx=WinMetrics(-3)
	CPUMATH=@FALSE
   wc=WinConfig()
   cputype= ItemExtract(6,WinSysInfo(),@tab)
	if wc&64 then cpu=8086
   	if wc&128 then cpu=80186
      if wc&2 then cpu=286
      if wc&4 then cpu=386
      if wc&8 then cpu=486
      if !(wc&1024)  then CPUMATH=@TRUE

;;;;;;;;;;;;;
; Get UName ;
;;;;;;;;;;;;;        
	UNAME=ItemExtract(1,WinSysInfo( ),@TAB)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Determine if Multiple Processors ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	CPUMULTI=@FALSE
	CPUN=ItemExtract(5,Winsysinfo( ),@TAB)
	if CPUN!=1 Then CPUMULTI=@TRUE

;;;;;;;;;;;;;;;;
; Detect Mouse ;
;;;;;;;;;;;;;;;;
mouse=@FALSE
        if WinMetrics(19) then mouse=@TRUE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Get Current Resolution Settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	VRES=strcat(WinMetrics(0),'x',WinMetrics(1))
	VColors=WinMetrics(-1)

;;;;;;;;;;;;;;;;;;;;;;;
; Check For SoundCard ;
;;;;;;;;;;;;;;;;;;;;;;;
	ErrorMode(@OFF)
   LastError()
   PlayMedia("Status WaveForm Ready")
   ErrorMode(@CANCEL)
	MMEDIA=@FALSE
   if LastError()!=1193 then MMEDIA=@TRUE        

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Get Physical memory available ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        PMEM=WinResources(11)/1024   ; Get Physical memory avail

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Check For a Removable Drive other than A: ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;      
   REMOV=@FALSE
	if strlen(strreplace(DiskScan(1),@TAB," "))>3 then REMOV=@TRUE


;;;;;;;;;;;;;;;;;;;;;;
; Get Hard Disk Info ;
;;;;;;;;;;;;;;;;;;;;;;
	hdisks=DiskScan(2)
   hdisks=strreplace(hdisks,@tab," ")
	If hdisks=="" 
	HD1Clusters="n/a"
	HD1Sectors="n/a"
	HD1BPS="n/a"
	HD1SIZE="n/a"
		else
		HD1Clusters=DiskInfo (StrSub(hdisks,1,1),4)
		HD1Sectors=DiskInfo (StrSub(hdisks,1,1),1)
		HD1BPS=DiskInfo (StrSub(hdisks,1,1),2)
		HD1SIZE=DiskSize(StrSub(hdisks,1,1))/1024000
		endif
	If strlen(hdisks)<4 
		HD2Clusters="n/a"
		HD2Sectors="n/a"
		HD2BPS="n/a"
		HD2SIZE="n/a"		
	   else
		HD21Clusters=DiskInfo (StrSub(hdisks,4,1),4)
		HD2Sectors=DiskInfo (StrSub(hdisks,4,1),1)
		HD2PBS=DiskInfo (StrSub(hdisks,4,1),2)
		HD2SIZE=DiskSize(StrSub(hdisks,4,1))/1024000
	   endif
	
;;;;;;;;;;;;;;;;;;;;
; Check For CD ROM ;
;;;;;;;;;;;;;;;;;;;;
	CDR=@TRUE
	If DiskScan(8)=="" then CDR=@FALSE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Check to See if OS is NT ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	if RegExistkey(@REGMACHINE, "Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\1")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ************* BEGIN WINDOWS NT SECTION ************;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;
; Get NIC Description ;
;;;;;;;;;;;;;;;;;;;;;;;
	Reghandl1=RegOpenKey(@REGMACHINE, "Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\1")
	NIC = RegQueryValue(Reghandl1,"[DESCRIPTION]")

;;;;;;;;;;;;;;;;;
; Get BIOS Info ;
;;;;;;;;;;;;;;;;;
	REGHANDL2=RegOpenKey(@REGMACHINE, "Hardware\Description\System")
	BIOSDATE=RegQueryValue(RegHandl2,"[SystemBiosDate]")
	BIOSVER=RegQueryMulSz(RegHandl2,"[SystemBiosVersion]"," ")

;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Determine how to get IP ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
	BATCHCOM="ipconfig /all > temp1.txt"


;;;;;;;;;;;;;;;;;;
; Get NT Version ;
;;;;;;;;;;;;;;;;;;
	OS=StrCat("Windows NT ",majorver, ".", minorver)
	REGHANDL3=RegOpenKey(@RegMachine, "Software\Microsoft\Windows NT\CurrentVersion")
	sub=RegQueryValue(RegHandl3,"[CurrentBuildNumber]")	
	OS=strcat(os,".",sub)


else
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ***************** BEGIN WINDOWS 95 SECTION ********************* ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;
; Get NIC Description ;
;;;;;;;;;;;;;;;;;;;;;;;
	If RegExistkey(@REGMACHINE,"System\CurrentControlSet\Services\Class\Net\0000")
		Reghandl1=RegOpenKey(@REGMACHINE,"System\CurrentControlSet\Services\Class\Net\0000")
	   else
		Reghandl1=RegOpenKey(@REGMACHINE,"System\CurrentControlSet\Services\Class\Net\0001")
		endif
	NIC=RegQueryValue(Reghandl1,"[DriverDesc]")

;;;;;;;;;;;;;;;;;
; Get BIOS Info ;
;;;;;;;;;;;;;;;;;
	BIOSDATE="Unknown"
	BIOSVER="Unknown"

;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Determine how to get IP ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
	BATCHCOM="winipcfg /BATCH /ALL C:\temp1.txt"

;;;;;;;;;;;;;;;;;;
; Get 95 Version ;
;;;;;;;;;;;;;;;;;;
	REGHANDL3=RegOpenKey(@RegMachine, "Software\Microsoft\Windows\CurrentVersion")
	wver=RegQueryValue(RegHandl3,"[VersionNumber]")
	sub=RegQueryValue(RegHandl3,"[SubVersionNumber]")
	OS=StrCat("Windows 95 ",wver,".",sub)
	endif


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Determine IP and MAC Addresses ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		; Create File To Read IP From ;
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			handle1=FileOpen("c:\temp1.bat","WRITE")
			FileWrite (handle1, BATCHCOM)
			FileClose(handle1)
			RunShell("c:\temp1.bat","","c:\", @normal,@wait)

		;;;;;;;;;;;;;;;;;;;;;;;;;;
		; Parse Through The File ;
		;;;;;;;;;;;;;;;;;;;;;;;;;;
			handle2=FileOpen("c:\temp1.txt","READ")
			:Loop1
				Dataline=FileRead(handle2)
				place=StrIndex(Dataline,"Physical Address",1,@FWDSCAN)
				if Place==0 then goto Loop1
			MAC=StrSub(Dataline,32,(strlen(Dataline)-31))
			:Loop2
				Dataline=FileRead(handle2)
				place=StrIndex(Dataline,"IP Address",1,@FWDSCAN)
				if Place==0 then goto Loop2
			IP=StrSub(Dataline,32,(strlen(Dataline)-31))
		;;;;;;;;;;;
		; Tidy Up ;
		;;;;;;;;;;;
			FileClose(Handle2)
			FileDelete ("C:\temp1|C:\temp.bat")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Draw And PopulateThe Main Form ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	MainFormat=`WWWDLGED,5.0`
	MainCaption=`Workstation Data Capture`
	MainX=0
	MainY=19
	MainWidth=395
	MainHeight=281
	MainNumControls=79
	Main01=`316,120,80,DEFAULT,CHECKBOX,CPUMATH,"Math co-processor",1`
	Main02=`330,30,40,DEFAULT,EDITBOX,BIOSDATE,"??/??/????"`
	Main03=`316,104,78,DEFAULT,CHECKBOX,CPUMULTI,"Multiple Processors",1`
	Main04=`146,30,36,DEFAULT,VARYTEXT,CPUTYPE,""`
	Main05=`6,184,40,DEFAULT,VARYTEXT,OS,""`
	Main06=`96,140,60,DEFAULT,CHECKBOX,MOUSE,"Mouse Present",1`
	Main07=`316,136,64,DEFAULT,CHECKBOX,MMedia,"Multimedia",1`
	Main08=`48,184,36,DEFAULT,VARYTEXT,Vres,""`
	Main09=`112,184,36,DEFAULT,VARYTEXT,VColors,""`
	Main10=`182,30,36,DEFAULT,VARYTEXT,PMem,""`
	Main11=`214,68,158,DEFAULT,VARYTEXT,NIC,""`
	Main12=`188,138,40,DEFAULT,CHECKBOX,cdr,"CD-ROM",1`
	Main13=`228,138,68,DEFAULT,CHECKBOX,REMOV,"Removable Drive",1`
	Main14=`188,114,46,DEFAULT,STATICTEXT,DEFAULT,"Hard Disk #1:"`
	Main15=`188,126,46,DEFAULT,STATICTEXT,DEFAULT,"Hard Disk #2:"`
	Main16=`112,172,48,DEFAULT,STATICTEXT,DEFAULT,"Colors"`
	Main17=`4,240,36,DEFAULT,STATICTEXT,DEFAULT,"NOTES:"`
	Main18=`48,172,64,DEFAULT,STATICTEXT,DEFAULT,"Video Resolution:"`
	Main19=`4,252,386,DEFAULT,EDITBOX,NOTES,""`
	Main20=`172,56,142,DEFAULT,STATICTEXT,DEFAULT,"**************NETWORK CARD**************"`
	Main21=`330,18,36,DEFAULT,STATICTEXT,DEFAULT,"Date"`
	Main22=`234,126,36,DEFAULT,VARYTEXT,HD2SIZE,""`
	Main23=`6,172,40,DEFAULT,STATICTEXT,DEFAULT,"Op Sys.:"`
	Main24=`324,168,64,DEFAULT,PUSHBUTTON,DEFAULT,"Reset",3`
	Main25=`58,2,84,DEFAULT,VARYTEXT,UNAME,""`
	Main26=`324,202,64,DEFAULT,PUSHBUTTON,DEFAULT,"EXIT",0`
	Main27=`4,160,152,DEFAULT,STATICTEXT,DEFAULT,"------------------------------SOFTWARE------------------------"`
	Main28=`324,184,64,DEFAULT,PUSHBUTTON,DEFAULT,"Submit",2`
	Main29=`228,30,100,DEFAULT,EDITBOX,BIOSVER,"Unknown"`
	Main30=`146,18,36,DEFAULT,STATICTEXT,DEFAULT,"CPU Type:"`
	Main31=`182,18,36,DEFAULT,STATICTEXT,DEFAULT,"Memory:"`
	Main32=`234,114,36,DEFAULT,VARYTEXT,HD1Size,""`
	Main33=`230,18,80,DEFAULT,STATICTEXT,DEFAULT,"BIOS VERSION"`
	Main34=`2,18,36,DEFAULT,STATICTEXT,DEFAULT,"Make:"`
	Main35=`2,30,36,DEFAULT,EDITBOX,PCMAKE,""`
	Main36=`38,18,36,DEFAULT,STATICTEXT,DEFAULT,"Model:"`
	Main37=`38,30,36,DEFAULT,EDITBOX,PCMODEL,""`
	Main38=`74,18,36,DEFAULT,STATICTEXT,DEFAULT,"Serial#:"`
	Main39=`74,30,36,DEFAULT,EDITBOX,PCSERIAL,""`
	Main40=`110,18,36,DEFAULT,STATICTEXT,DEFAULT,"Asset#:"`
	Main41=`110,30,36,DEFAULT,EDITBOX,PCASSET,""`
	Main42=`4,64,36,DEFAULT,STATICTEXT,DEFAULT,"Make:"`
	Main43=`40,64,36,DEFAULT,STATICTEXT,DEFAULT,"Serial#:"`
	Main44=`76,64,36,DEFAULT,STATICTEXT,DEFAULT,"Asset#:"`
	Main45=`6,52,100,DEFAULT,STATICTEXT,DEFAULT,"***********MONITOR***********"`
	Main46=`4,76,36,DEFAULT,EDITBOX,MONMAKE,""`
	Main47=`40,76,36,DEFAULT,EDITBOX,MONSERIAL,""`
	Main48=`76,76,36,DEFAULT,EDITBOX,MONASSET,""`
	Main49=`6,114,36,DEFAULT,STATICTEXT,DEFAULT,"Serial#:"`
	Main50=`6,126,36,DEFAULT,EDITBOX,KEYSERIAL,""`
	Main51=`42,114,36,DEFAULT,STATICTEXT,DEFAULT,"Asset#:"`
	Main52=`42,126,36,DEFAULT,EDITBOX,KEYASSET,""`
	Main53=`96,114,36,DEFAULT,STATICTEXT,DEFAULT,"Serial#:"`
	Main54=`132,114,36,DEFAULT,STATICTEXT,DEFAULT,"Asset#:"`
	Main55=`96,126,36,DEFAULT,EDITBOX,MSSERIAL,""`
	Main56=`132,126,36,DEFAULT,EDITBOX,MSASSET,""`
	Main57=`10,102,64,DEFAULT,STATICTEXT,DEFAULT,"****KEYBOARD****"`
	Main58=`98,102,68,DEFAULT,STATICTEXT,DEFAULT,"*******MOUSE*******"`
	Main59=`172,68,42,DEFAULT,STATICTEXT,DEFAULT,"Description:"`
	Main60=`166,80,48,DEFAULT,STATICTEXT,DEFAULT,"MAC Address:"`
	Main61=`214,80,100,DEFAULT,VARYTEXT,MAC,""`
	Main62=`270,114,36,DEFAULT,STATICTEXT,DEFAULT,"Meg"`
	Main63=`270,126,36,DEFAULT,STATICTEXT,DEFAULT,"Meg"`
	Main64=`188,102,112,DEFAULT,STATICTEXT,DEFAULT,"**************DRIVES**************"`
	Main65=`184,190,36,DEFAULT,STATICTEXT,DEFAULT,"Make:"`
	Main66=`220,190,36,DEFAULT,STATICTEXT,DEFAULT,"Model:"`
	Main67=`186,178,104,DEFAULT,STATICTEXT,DEFAULT,"*************PHONE*************"`
	Main68=`256,190,36,DEFAULT,STATICTEXT,DEFAULT,"Extension:"`
	Main69=`184,202,36,DEFAULT,EDITBOX,PHMAKE,""`
	Main70=`220,202,36,DEFAULT,EDITBOX,PHMODEL,""`
	Main71=`256,202,36,DEFAULT,EDITBOX,EXTEN,""`
	Main72=`4,214,64,DEFAULT,STATICTEXT,DEFAULT,"Misc. Accessories:"`
	Main73=`4,226,386,DEFAULT,EDITBOX,MISC,""`
	Main74=`2,2,56,DEFAULT,STATICTEXT,DEFAULT,"Computer Name:"`
	Main75=`156,2,40,DEFAULT,STATICTEXT,DEFAULT,"User Name:"`
	Main76=`196,2,64,DEFAULT,EDITBOX,First,""`
	Main77=`262,2,64,DEFAULT,EDITBOX,Last,""`
	Main78=`246,266,44,DEFAULT,STATICTEXT,DEFAULT,"Save File To:"`
	Main79=`292,266,98,DEFAULT,EDITBOX,DBFile,"DbFile"`
	ButtonPushed=0
	:WAIT
	ButtonPushed=Dialog("Main")
	If ButtonPushed==0 then goto wait
	If ButtonPushed==1 then exit
	If ButtonPushed==3 then goto LOADVAR

:SUBMIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Create the string to write out to the log file ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	DATA=StrCat(UNAME,"|",First,"|",LAST,"|",CPUMATH,"|",CPUMULTI,"|",CPUTYPE,"|",OS,"|",MOUSE,"|",MMEDIA,"|")
	DATA=StrCat(DATA,VRES,"|",VCOLORS,"|",PMEM,"|",NIC,"|",CDR,"|",REMOV,"|")
	DATA=StrCat(DATA,HD1SIZE,"|")
	DATA=StrCat(DATA,HD2SIZE,"|",NOTES,"|")
	DATA=StrCat(Data,BiosVer,"|",BiosDate,"|")
	DATA=StrCat(Data,PCMAKE,"|",PCMODEL,"|",PCSERIAL,"|",PCASSET,"|")
	DATA=StrCat(DATA,MONMAKE,"|",MONSERIAL,"|",MONASSET,"|",KEYSERIAL,"|",KEYASSET,"|")
	DATA=StrCat(DATA,MSSERIAL,"|",MSASSET,"|",MAC,"|",PHMAKE,"|")
	DATA=StrCat(DATA,PHMODEL,"|",EXTEN,"|",MISC,TimeDate())

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Post Info To The Log File ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Handle=FileOpen(DBFILE,"APPEND")
FileWrite (Handle,DATA)
FileClose (Handle)

Message ("Complete","Database File Updated")

Article ID:   W14489
Filename:   Collect Info about Workstations including MAC.txt
File Created: 2000:04:06:10:48:02
Last Updated: 2000:04:06:10:48:02