Refresh Environment

  • Print

When deploying a product with Setup Factory, sometimes you wish to add the installation path to the PATH environment variable. Although you can do that pretty easily by adding the new information to the registry, these changes do not take effect until the user logs into his Windows account again. This utility attempts to overcome this limitation.

Here is a short sample how you can use this utility, normally executed during your On Post Install event:

 
envKey = "System\\CurrentControlSet\\Control\\Session Manager\\Environment";
path = Registry.GetValue(HKEY_LOCAL_MACHINE, envKey, "Path", false);
 
if (String.Find(path, SessionVar.Expand("%AppFolder%"), 1, false) == -1) then
    -- %AppFolder% not found in the current path, so add it now
    path = path .. ";" .. SessionVar.Expand("%AppFolder%");
    -- update registry
    Registry.SetValue(HKEY_LOCAL_MACHINE, envKey, "Path", path, REG_EXPAND_SZ)
    SetupData.WriteToLogFile("Info\tNew Path=" .. path .. "\r\n", true);
    -- refresh the environment (execute primer file)
    File.Run(SessionVar.Expand("%TempLaunchFolder%\\RefreshEnvironment.exe"), "", "",
        SW_MINIMIZE, true);
    error = Application.GetLastError();
    if (error ~= 0) then
        SetupData.WriteToLogFile("Error\tCould not execute utility!\r\n", true);
    end
end 

You would typically add the utility to the Primer Files of your project, so it would be deleted automatically when the installer finished.

Download

Click to downloadFile size: 15 KB
Updated: September 2010

Don't have Setup Factory?

If you want to purchase a license for Setup Factory 9, now is a good time! You can get 10% off the list price simply by clicking the banner below:

 

Comments 

 
# Toma 2012-11-09 16:06
Thanks for this, i almost ripped the rest of my already thin hair before I found this solution.
 

Add a comment (For questions, please use the contact form!)

Security code
Refresh

Our Plugins & Examples Feed

  • POP3 Actions plugin released

    A new, free actions plugin was released today. With it, the developer can check POP3...

  • Reminder: Update Serial Number Validation and/or Subscription Validation

    Next week IPInfoDB's API 2.0 will stop working. If you use an older version than...

Subscribe now!

Advertisement