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 (530 Views)
Accepted Solution

BIOS serial number

530 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,

 

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 2 of 4 (515 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 (499 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,461
Registered: ‎11-24-2009
Message 4 of 4 (495 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

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.