/build/static/layout/Breadcrumb_cap_w.png

How To Get The Variables Environements

Registry



For All Currents Users  there are to hive :

HKEY_CURRENT_USER \ Environment
This hive is just a copy of  HKEY_USERS\.DEFAULT\Environment. Give the location of the TEMP directory for the current user.

For the Current user session  

HKEY_CURRENT_USER\Volatile Environment
This one is very usefull, for Custum Action. Because the CA run with the system user. Here a short list of the environments variables (not all of them) : 

%APPDATA%
%USERNAME%
%USERPROFILE%
%USERDOMAIN%

For the system :

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ Environment
With this hive, there all the environements variables display when we type "set" command in DOS. This is the list of the main variables : 
%Path%, %ComSpec%, %windir%, %PROCESSOR_ARCHITECTURE%


VBScript Sample 

Set WshShellObj = WScript.CreateObject("WScript.Shell") 
'context : Process, System, Volatile
context = "User" 
Set WshProcessEnv = WshShellObj.Environment(context)  
WScript.Echo WshProcessEnv("USERNAME")


Custom Action (Set Property)

With User Interface


With the table




Do you have other tips or tricks about Variable Environment ?

Comments

  • Instead of making a custom action (because I hate them!) when I need a system variable, I always set a Public Property at the command line, like so: "msiexec asdf.msi PROPERTY123=%LOGONSERVER%". Much more efficient and faster to create. - vjaneczko 10 years ago
    • Ok, that's a good one. Thanks for this advice. - egiberne 10 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ