Go Back

why would GETLOG not pick up environment variables set in a BAT file, but pick them up if defined as system environment variables

I have an application which runs locally on 22 PCs and as a published app on 4 terminal servers quite happily.

The application is started up via a BAT file, which defines things such as server names as environment variables, which getlog then picks up and uses when deciding how to open files via xfserver

So it works well and has done for 3 years

However we repalced one of the PCs and teh application wouldn't pic up the environhment variables defined in the BAT file, which is the same BAT file used everywhere else.

We checked that the varioables were set correctly after running the application by echoing them, but the application dwouldnm;t picvk these up.

We then set the env vars up as system env vars and the application worked.

Teh same thing happened with defining SFWINIPATH.  It didn't pick this up form the BAT file, but did pick it up when defined as a system env var.

This is windows 10, running synergy 10.3.3c

Any ideas what might be happening ?

4 Answers
0   | Posted by Gordon Ireland to Synergy DBL on 11/19/2018 12:55 PM
Ace Olszowka
At what level are the environment variables set and under what context did the batch file run? Did you run the batch file from a service, the login process, or a UAC context?

When you say "System" are you talking actual Windows System Level Environment Variables (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment)? Or are you talking about User Environment Variables (HKEY_CURRENT_USER\Environment) at the System Level?

11/29/2018 10:57 PM   0  
Kish Baley
I suspect the other PCs may be running different version of Windows and/or Synergy, please confirm.

It would help if you provided a portion of the .bat file, specifically how you call the application within the .bat file. Also, how is the .bat file run, do you open a Windows CMD prompt and run it or do you click on the .bat file from the desktop/file explorer?

EVs defined with the SET command exist only in the process space that created them or in any child process. It sounds like the application is not running as a child process but is instead running in its own process space. I believe Windows 10 is less likely to create child processes as previous versions did.

As you already observed, setting the EVs in the system environment vars will solve the issue because those are inherited by every process. One way around this is to use SETX instead of SET in your .bat file:


SETX /m is the same as entering the EVs into the System Properties>Advanced>Environment Variables... so you only need to run the .bat file once unless something changes. I prefer a .bat file with SETX vs. manually editing the system environment vars because the .bat file can be source controlled and therefore show history of changes.


11/30/2018 12:04 AM   0  
Ace Olszowka
Be extremely careful with SETX as it will truncate anything over 1024 Characters

11/30/2018 2:07 PM   0  
Kish Baley

I wrote a small .bat file and .dbl but could not replicate your issue. I'm running Win10 with 10.3.3f.

My .bat file:
  set ROOT=%~dp0
  set MyLogical=c:\SomeDir\
  dbr "%ROOT%\Debug\x64\Program1"

then in Program1.dbl:
  getlog("MyLogical", logval, loglen)

and when I run the .bat file, the app reports that logval=c:\SomeDir\.

Not sure why yours is not working.

11/30/2018 7:14 PM   0  
Please log in to comment or answer this question.