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.

Extract S/N from Bios

Keywords:    extract s/n from bios wmi

Question:

I was able to extract the S/N from Bios with a VBS script but it only seemed to work on W2K systems. I found a Pascal script that worked but I am unfamilier with Pascal. Can Winbatch get this job. Attached is the VBS script if it helps.
Dim FSO, AFile, AFileStream
Dim strSrcDir

' Set variables
strSrcDir = "c:\"

Set SNSet = GetObject("winmgmts:").InstancesOf ("Win32_BIOS")

Set FSO = CreateObject("Scripting.FileSystemObject")

Set AFileStream = FSO.OpenTextFile("C:\SN.txt",8)


for each SN in SNSet
	AFileStream.WriteLine SN.SerialNumber
Next

Answer:

If you have a current version of WinBatch.



Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer()
Security = Service.Security_
Security.ImpersonationLevel = 3
Class = "Win32_Bios"
Instance = Service.InstancesOf(Class)
hEnum = ObjectCollectionOpen(Instance)
While 1
  Obj = ObjectCollectionNext(hEnum)
  If Obj == 0 Then Break
  sn=Obj.SerialNumber
  desc=Obj.Description

  Message(Class, StrCat(desc,@CRLF,sn))
EndWhile
ObjectCollectionClose(hEnum)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)


Article ID:   W15357
File Created: 2003:05:28:10:25:06
Last Updated: 2003:05:28:10:25:06