Visual LISP, AutoLISP and General Customization

Reply
Valued Mentor
jclaidler
Posts: 512
Registered: ‎10-29-2009
Message 1 of 7 (417 Views)
Accepted Solution

LISP: Determine OS

417 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"))

_______________________________________________________________
ITO - Application Management
AutoCAD 2014 | Inventor Professional 2014 | Vault Professional 2014

*Expert Elite*
dgorsman
Posts: 5,115
Registered: ‎10-12-2006
Message 2 of 7 (412 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.


Valued Mentor
jclaidler
Posts: 512
Registered: ‎10-29-2009
Message 3 of 7 (406 Views)

Re: LISP: Determine OS

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

Found it!!!!

 

(getvar "platform")

 

_______________________________________________________________
ITO - Application Management
AutoCAD 2014 | Inventor Professional 2014 | Vault Professional 2014

*Expert Elite*
Lee_Mac
Posts: 1,128
Registered: ‎12-29-2009
Message 4 of 7 (398 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?
Valued Mentor
jclaidler
Posts: 512
Registered: ‎10-29-2009
Message 5 of 7 (394 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.

_______________________________________________________________
ITO - Application Management
AutoCAD 2014 | Inventor Professional 2014 | Vault Professional 2014

Distinguished Contributor
dolives
Posts: 207
Registered: ‎09-04-2002
Message 6 of 7 (312 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 (307 Views)

Re: LISP: Determine OS

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

file attach

 

Daniel OLIVES

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community