Jump to content

how to reload environment variables


ur
 Share

Recommended Posts

I am installing an setup.exe file through autoit runwait.

And after installation , I need to test the application shortcut.

Initially I have completed installation part and the shortcut functionality part I have done separately.

Both are working as separate exe files(.au3 compiled versions).

But as a final product, when I combined both of them, I am getting the error during shortcut launch as JRE_HOME variable not set.

I think, when both are separate exe files, the env. variable is being set by setup file during first au3 file.

And for second au3 as it is completely separate executable, it is loading the env variables from system at that point of time.

But for combined version, even though it is being set in the system, the au3 being run is not taking the latest values set during its runtime.

I tried restarting the explorer process also by using 

Run("explorer.exe",Call(ProcessClose("explorer.exe")));restart explorer

But still no use.

Can anyone provide your suggestions, how to handle this.

Link to comment
Share on other sites

  • Developers

Did you try EnvUpdate() ?

Jos

Ps: Don't know how you dreamed up that Run() statement but it looks quite "creative"

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
20 minutes ago, ur said:

But the EnvUpdate is also not helpful.

I am still getting the below prompt during the application launch.

What about you share the script so we understand why you get this error? 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

16 minutes ago, aa2zz6 said:

I did a google search and maybe this will help you setup the java environment variables with an Autoit script.

http://trompelecode.com/blog/2009/04/autoit-script-to-set-java-home/

The env variable is setting up by the setup.exe itself which i am executing using runwait from my autoit script.

It is updating in the env variables also.

But as already the au3 process started earlier itseld, the current process is not loading the variables

Link to comment
Share on other sites

THe env variable is being set by a thridparty setup file which I am launching from RunWait.

Once the process is completed, I am launcing the shortcut it created and it needs JRE_HOME , which is set by exe.

ANd it is creating also, I can check that by launching cmd and typing %JRE_HOME%

But our au3 file is not loading that.

Even after EnvUpdate() also.It is showing the empty messagebox for below code.

MsgBox(0,"",EnvGet("JRE_HOME"))
EnvUpdate();reload env. variables
MsgBox(0,"",EnvGet("JRE_HOME"))

Any suggestions?

Link to comment
Share on other sites

Initially both are two separate scripts.

1. For installation of 3rd party setup file.

2. For launching its shortcut and doing the functionality testing.

At that time it worked as the 2nd part is a separate process completely.

Now when I combined them, it is failing to load the variables created in the first part.

 

 

Link to comment
Share on other sites

As a temporary solution, I am reading the registry value for environment variables and setting it for the session.

Local $jre_env = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "JRE_HOME")
    If Not @error Then
        Logging ("JRE_HOME from registries "& $jre_env)
    Else
        Logging ("Error : Unable to Retrieve JRE_HOME env variable from Registries")
        Exit
    EndIf
    EnvSet("JRE_HOME", $jre_env);set JRE_HOME = $jre_env
    
    Func Logging($sMessage,$sLogFile=@ScriptDir&"\Logging.log")
    If $sMessage = "" Then
        FileWriteLine($sLogFile, "")
    Else
        FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF)
    EndIf
    EndFunc

Please let me know if you find any.

Link to comment
Share on other sites

With a different user? But I need to launch program with the logged in user only. I will use the runas with same user credentials, may be it might work.i will let you know my inputs

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...