Re: How to create "user environment variables" programatically for a non-logged on user



Mel wrote:
> Regd the restriction, well let me explain briefly the problem. My
> installation program embeds a 3rd party software which I install in
> silent mode. Now this 3rd party software installs 2 services. Both
> these services unfortunately use a common environment variable. This
> environment variable has to have 2 different values for the 2
> services to come up at the same time. I thought I would create 2
> users and have that environment variable as a "user environment
> variable", so that I can specify different values for each user. Then
> I would specify each of the 2 services to use the 2 different user
> accounts that I create.
> Logging in the user through LogonUser() api is fine with me.
>
> Is there some other way to solve that problem without creating 2
> users?

Yes there is an easy solution. (A real good one is of course to force the
3rd party vendor to fire the managers of the project that relied on
environment variables on Win32).

The thing to realize is that the process that does the service-ish things
(like StartServiceControlDispatcher etc.) doesn't necessarily have to be the
same process that is started by SCM. All that matters is that some service
starts and in a short period of time some process connects to SCM. Which
gives you a way to insert your own process between SCM and the 3rd party
service.
Write a small console application that will read the needed value from
config file or registry, set the environment variable to this value and then
invoke the service process. Then wait for the service process to die. The
waiting step is important because SCM waits for the process it started and
if it dies pops up the familiar dialog about "the service process terminated
unexpectedly". Make the service entry in registry point to your exe instead
of the original one and you are all set.

I should also mention that if you don't want to change the registry entries
for the service for whatever reason you can also use "Image File Execution
Options" key. Google for this key name to find out what it does.

--
Eugene
http://www.gershnik.com



.



Relevant Pages

  • libwrap not found (building netatalk on Solaris 9)
    ... version used by Solaris 9. ... I could install the standard tcpwrappers from ... The "influential environment variables" ... an installation prefix other than `/usr/local' using `--prefix', ...
    (SunManagers)
  • Re: Environment Variable Load Order
    ... to manually change the paths myself so that it works for the 31 machines I ... Does anyone know the order in which environment variables are ... loaded upon user log in? ... This works as expected just after the installation (PATH is effectively ...
    (microsoft.public.windowsxp.general)
  • Re: Environment Variable Load Order
    ... Does anyone know the order in which environment variables are ... loaded upon user log in? ... I have an installation program which sets one system environment variable: ...
    (microsoft.public.windowsxp.general)
  • Re: How to get GIF support with Perl-GD library? (Cant locate object method "newFromGif")
    ... Fine tuning of the installation directories: ... Some influential environment variables: ... CXXFLAGS C++ compiler flags ...
    (comp.lang.perl.modules)
  • Re: Code Download Error: (hr = 800c0300) Unknown Error
    ... > once I start using the 3rd party software in the control. ... > listed in redist.txt but the CAB installation still fails with this ... >> have to digitally sign it in order to use it with default IE security. ...
    (microsoft.public.vb.controls.internet)