Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP: Determine OS

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
john.laidler
1099 Views, 6 Replies

LISP: Determine OS

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
AutoCAD, Inventor and Vault



Please use "Accept as Solution" & give "Kudos" if this response helped you.
6 REPLIES 6
Message 2 of 7
dgorsman
in reply to: john.laidler

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.
"I don't know" is the beginning of knowledge, not the end.


Message 3 of 7
john.laidler
in reply to: dgorsman

Found it!!!!

 

(getvar "platform")

 

John Laidler
AutoCAD, Inventor and Vault



Please use "Accept as Solution" & give "Kudos" if this response helped you.
Message 4 of 7
Lee_Mac
in reply to: john.laidler

Alternatively,

 

(getenv "OS")

 

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

Message 5 of 7
john.laidler
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
AutoCAD, Inventor and Vault



Please use "Accept as Solution" & give "Kudos" if this response helped you.
Message 6 of 7
dolives
in reply to: john.laidler

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:osinfo (/ 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:pcinfo (/ 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) )

Message 7 of 7
dolives
in reply to: dolives

file attach

 

Daniel OLIVES

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost