Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
jclaidler
Posts: 581
Registered: ‎10-29-2009
Message 1 of 7 (436 Views)
Accepted Solution

LISP: Determine OS

436 Views, 6 Replies
08-26-2013 08:35 AM

Is there a way with (vl-registry-read) to determine which OS is currently being used?

Example:  the below code returns 'nil'.

 

(vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName"))

John Laidler

Found it!!!!

 

(getvar "platform")

 

*Expert Elite*
dgorsman
Posts: 5,698
Registered: ‎10-12-2006
Message 2 of 7 (431 Views)

Re: LISP: Determine OS

08-26-2013 08:59 AM in reply to: jclaidler

Not that I know of.  But OS changes happen relatively infrequently, so I think a simple solution would be to prompt the user and create your own registry key when missing and silently read it when present.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


*Expert Elite*
jclaidler
Posts: 581
Registered: ‎10-29-2009
Message 3 of 7 (425 Views)

Re: LISP: Determine OS

08-26-2013 09:26 AM in reply to: dgorsman

Found it!!!!

 

(getvar "platform")

 

John Laidler

*Expert Elite*
Lee_Mac
Posts: 1,270
Registered: ‎12-29-2009
Message 4 of 7 (417 Views)

Re: LISP: Determine OS

08-26-2013 10:07 AM in reply to: jclaidler

Alternatively,

 

(getenv "OS")

 

Though, being an environment variable, this is still reading from the registry.

Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)
Expert Elite
With Mathematics there is the possibility of perfect rigour, so why settle for less?
*Expert Elite*
jclaidler
Posts: 581
Registered: ‎10-29-2009
Message 5 of 7 (413 Views)

Re: LISP: Determine OS

08-26-2013 10:13 AM in reply to: Lee_Mac

That doesn't list if the OS is XP, Vista or Windows 7. It returns 'Windows NT'. (getvar "platform") accomplishes the versions.

John Laidler

Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 6 of 7 (331 Views)

Re: LISP: Determine OS

09-03-2013 08:37 AM in reply to: jclaidler
Spoiler
 

Hy,

You can use WMI information

Daniel OLIVES

 

;**************************************************************************** (defun c:info (/ 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")         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 "\nCaractéristiques " process " :"))     (vlax-for item meth2       (lister (vlax-get item 'Properties_))       (lister (vlax-get item 'Qualifiers_))       (getkword "\nAppuyez sur entrée pour continuer...")     )   )   (mapcar 'vlax-release-object (list meth1 meth2 wmi))   (LecCmdXml "TPS_02_Divers.lsp" "INFO")   (princ) ) ;**************************************************************************** (defun c:smileysurprised:sinfo (/ WMI Serv OSArch item prop)   (vl-load-com)   (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")         Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)         OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch     (vlax-for prop (vlax-get item 'Properties_)       (princ (vlax-get prop 'Value))    (setq valos (vlax-get prop 'Value))     )   )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))   (LecCmdXml "TPS_02_Divers.lsp" "OSINFO")   (Msgbox "Technip TPS - Contrôle 32/64 bits" 64 (strcat "Votre OS est une version :  " valos))   (princ)  )  ;**************************************************************************** (defun appli (qui / apps item lst meth1 meth2 WMI)

  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")         meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)         meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process"))   (vlax-for item meth2 (setq lst (cons (vlax-get item 'CommandLine) lst)))   (foreach item (list WMI meth1 meth2)     (vlax-release-object item)   )   (vl-remove-if-not '(lambda(x) (and x (vl-string-search (strcase qui)  (strcase x)))) lst) ) ; (while (appli "cmd.exe")  ;**************************************************************************** (defun c:smileytongue:cinfo (/ 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")         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 "\n\t\tCaractéristiques du processus \"" process "\""))     (vlax-for item meth2       (lister (vlax-get item 'Properties_))       (lister (vlax-get item 'Qualifiers_))       (getkword (strcat "\nAppuyez sur sur entrée pour continuer..." Process))     )   )   (vlax-release-object meth1)   (vlax-release-object meth2)   (vlax-release-object wmi)   (LecCmdXml "TPS_02_Divers.lsp" "PCINFO")   (princ) )

Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 7 of 7 (326 Views)

Re: LISP: Determine OS

09-03-2013 09:18 AM in reply to: dolives

file attach

 

Daniel OLIVES

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.