WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Environment

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Environment Issue from PopMenu

 Keywords: User System Envirnonment Variables Popmenu

Question:

For some reason the Environment function is unable to get the same information that I see in the registry for both User and System Envirnonment Variables. The documentation for the Environment function states that it can retrieve either a system environment variable or a user environment variable. These variables are defined in the { Advanced tab } [Environment Variables] using Sysdm.cpl.

As I understand it the 'Environment' function is retrieving the value from the the environment block of the WinBatch process running the script. That block is inherited from the parent process that started the process running WinBatch. The parent process is usually either the Explorer.exe or cmd.exe but it could be something else. It all depends on how you start WinBatch (or your compiled script.)

So the question is how did the process starting my get the environment variables it is passing to WinBatch. Here are my tests and their results. The issue seems related to the popmenu somehow.

  1. Started WinBatch Navigator from Windows Start - Run a WBT - picked my WBT - Results are correct
  2. Started WinBatch Navigator from Windows Start - started Studio - opened my WBT - run/debugged it - Results are correct
  3. Started WinBatch Studio from Windows Start - opened my WBT - run/debugged it - Results are correct
  4. used WinBatch PopMenu - started Studio - opened my WBT - run/debugged it - Results are not right
  5. used WinBatch PopMenu - started Navigator - Run a WBT - picked my WBT - Results are not right
  6. run compiled script - Results are correct
How each of these processes get kicked off, I do not know (Explorer.exe or cmd.exe or something else) - they appear to me to all be .exe's. It also appears that WinBatch PopMenu is the distinguishing component. Do I have to do (should I have done) something with this component after the install made it available on the systray??

Answer:

PopMenu is no different than any other executable in this regard. It receives the environment block of the process starting it - Explorer by default. However, PopMenu is started as part of the login session creation process, so the Explorer's environment block can be modified by other applications, drivers or services after PopMenu has started but before the session login is finished. This appears to be the case for you.

If you plan on using PopMenu to start your sundry scripts that require your environment variable then you could modify PopMenu's environment block variables to match your needs. There are several ways to do this but the simplest may be to be editing the the PopMenu menu file PopMenu.mnw to add code to check and set the variable as needed. This could be done in either the top section of the menu file or in the section for each menu item that requires the variable to be correctly set. Another approach would be to kill and restart PopMenu after the login process has completed but this has some obvious drawbacks.


Article ID:   W17860
Filename:   Environment Issue from PopMenu.txt
File Created: 2013:07:16:08:15:26
Last Updated: 2013:07:16:08:15:26