Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 1 of 4 (592 Views)
Accepted Solution

BIOS serial number

592 Views, 3 Replies
02-13-2013 12:16 PM

Hi,

 

I know that in the MS Windows' "command prompt windows" I can type:

 

WMIC BIOS GET SERIALNUMBER

 


to get BIOS serial number. so how can I get it with LISP?

 

Thanks,

 


aqdam1978 wrote:

So, does anybody can summerize it to a single function that gives me just Bios.SerialNumber as a string variable?

 

Thanks,

 


(defun c:SerialInfo (/ WMI meth1 meth2 serial)
(vl-load-com)
(cond ((and (setq WMI (vlax-create-object "WbemScripting.SWbemLocator"))
(setq meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))
(setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" "BIOS")))
(vlax-for itm (vlax-get (vlax-invoke meth2 'ItemIndex 0) 'Properties_)
(if (eq (vlax-get itm 'name) "SerialNumber")
(setq serial (vlax-get itm 'value)))))))
(mapcar 'vlax-release-object (list meth1 meth2 wmi))
serial)

 

HTH

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 2 of 4 (577 Views)

Re: BIOS serial number

02-13-2013 02:04 PM in reply to: aqdam1978

Hi

 

I also find another way via VBS

 

make a text file and rename it to 1.vbs

paste below code and save and double click on icon:

 

On Error Resume Next
Dim strComputer
strComputer = InputBox("Enter the name of the computer:")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
MsgBox strComputer & ": " & objSMBIOS.SerialNumber
Next

 

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 3 of 4 (561 Views)

Re: BIOS serial number

02-13-2013 06:46 PM in reply to: aqdam1978

Hi

 

here a lisp program that extract all system information:

(defun c:SystemInfo(/ item meth1 meth2 process wmi)
	(defun lister(val / it)
		(vlax-for it val
			(princ (strcat "\n" (vlax-get it 'name) " : "))
			(if (vlax-get it 'value) (princ (vlax-get it 'value)) (princ "Nil"))
		)
	)

(vl-load-com)
(setq WMI (vlax-create-object "WbemScripting.SWbemLocator"))
(setq meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))

(foreach process (list "BIOS" "Processor" "VideoController" "SoundDevice" "CDROMDrive" "OperatingSystem" "ComputerSystem" "PhysicalMemory" "DiskDrive")
	(setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" Process)))
	(princ (strcat "\nfeatures of " process " :"))
	(vlax-for item meth2
		(lister (vlax-get item 'Properties_))
		(lister (vlax-get item 'Qualifiers_))
		(getkword "\nPress Enter to continue...")
	)
);;foreach
(mapcar 'vlax-release-object (list meth1 meth2 wmi))
(princ)
)

 So, does anybody can summerize it to a single function that gives me just Bios.SerialNumber as a string variable?

 

Thanks,

 

*Expert Elite*
pbejse
Posts: 2,511
Registered: ‎11-24-2009
Message 4 of 4 (557 Views)

Re: BIOS serial number

02-13-2013 07:24 PM in reply to: aqdam1978

aqdam1978 wrote:

So, does anybody can summerize it to a single function that gives me just Bios.SerialNumber as a string variable?

 

Thanks,

 


(defun c:SerialInfo  (/ WMI meth1 meth2 serial)
  (vl-load-com)
  (cond ((and (setq WMI (vlax-create-object "WbemScripting.SWbemLocator"))
              (setq meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))
              (setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" "BIOS")))
              (vlax-for itm  (vlax-get (vlax-invoke meth2 'ItemIndex 0) 'Properties_)
                (if (eq (vlax-get itm 'name) "SerialNumber")
                  (setq serial (vlax-get itm 'value)))))))
  (mapcar 'vlax-release-object (list meth1 meth2 wmi))
  serial)

 

HTH

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.