Re: Urgent...... Issues with GetEnvironmentVariable( ) on Win2k PRO SP4

From: JJ (jjjj_at_nospam.com)
Date: 10/27/04


Date: Wed, 27 Oct 2004 11:25:05 -0400


>>I have a previous version of the application( say V1 ) installed in a
home called C:\test1 & the later version ( say V2 ) in another home
called C:\test2.<<

I don't understand what you are saying here. What does the directory where
an executable is installed have anything to do with what environment
variables it gets?

When you have an application installed as a service and it is running in the
System account, it inherits its environment at boot time from the Service
Control Manager (SCM), which has only the values of the System Environment
Variables. Additionally, changing the System Environment Variables will not
affect the service, even between stops and restarts of the service because
the SCM has already inherited its environment. Only rebooting the system
will change them.

"Gary" <debugger@newsgroup.nospam> wrote in message
news:QAOfd.31$am3.33@news.oracle.com...
> Hi Experts,
> I have an application that is installed as a service. Say the service
> name is SRVC.
> I have a previous version of the application( say V1 ) installed in a
> home called C:\test1 & the later version ( say V2 ) in another home
> called C:\test2.
> For V1, the value of a variable %home% is defined to be "C:\test1" in
> the registery & for V2 it is defined to be "C:\test2" . Now for version
> V2 ( note that V1 is not running now ), when I am doing
> GetEnvironmentVariable(), to get the value of %home%, I am getting
> "C:\test1" , whereas I should have got "C:\test2".
> In the code, the logic is such that....... try GetEnvironmentVariable
> to get, if anything is defined or else goto the registery to get the
> value. I debugged to find that in the faulty case,
> GetEnvironmentVariable is returning "C:\test1" , though the V2 version
> of the appln is running & I should have got "C:\test2".
> The registery entries are just fine & I am sure that there are no
> silly or minor issues. When I reboot the box ( Win2k Pro, sp4 ) then
> everything is working fine. After the reboot, I noticed that
> GetEnvironmentVariable returns ERROR_ENVVAR_NOT_FOUND & we go to the
> registery to fetch the value. I am suspecting that there might be some
> stale memory issues which is being returned by GetEnvironmentVariable().
> How does GetEnvironmentVariable work in case of a appln that is running
> as a service ? For an appln started from the shell, its understandable
> that the appln will inherit the env vars defined in the shell. Can there
> be issues with GetEnvironmentVariable ???
> This is a very critical issue for us. Any help is greatly appreciated.
>
> Thanks,
> Gary.



Relevant Pages

  • Re: GenEnvironmentVariable and CreateProcess failures under XP
    ... environment variable was not found in the environment block. ... If you first call GetEnvironmentVariable with a 0-length string, ... It does not affect the "system environment" that other ... CreateProcess to launch Notepad or other Win32 executables. ...
    (microsoft.public.vb.winapi)
  • Re: odd behavior on client installation
    ... And being an environment variable, ... keys, *AND* clean up the system environment ... expecting, leading to my purge of Oracle from the system being ... presence of environment settings being set from places I had never ...
    (comp.databases.oracle.server)
  • RE: SetEnvironmentVariable in Debug and Release cofiguratin
    ... Calling SetEnvironmentVariable has no effect on the system environment ... The user can add or modify system environment variables using the ... Control Panel. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unable to access system environment variables under IIS 6
    ... Changing system environment variable requires rebooting the server for it ... launch CMD.EXE from the Start Menu's ...
    (microsoft.public.inetserver.iis)
  • Regarding SCM...
    ... I would like to know where does the SCM stores the system wide ... environment values (e.g path, tmp etc) which are finally inherited by ... Is it in registery? ...
    (microsoft.public.win32.programmer.kernel)

Quantcast