I've no idea if this is useful, but I've found that for every service, there is an option to add environment variables directly to a service.
It is done via the registry.
Say the key to your service is ...
HKLMSYSTEMCurrentControlSetServicesYourService
Create a REG_MULTI_SZ called Environment.
Now you can add entries like ...
Var1=Value1
Var2=Value2
and these will be available to the service code.
If you are using the Windows Resource ToolKit to install scripts as a service (instsrv.exe and srvany.exe), then, again, you have the option of setting Environment variables for the service, but most likely it is the wrong one as these would be for srvany.exe.
Instead, you use the key ...
HKLMSYSTEMCurrentControlSetServicesYourServiceParameters
and create a REG_MULTI_SZ called AppEnvironment
Set the entries in the same way.
And now your script service has it's own environment variables.
I'm using these techniques with PHP+WinCache to allow me to set an APP_POOL_ID unique to each service which allows WinCache to share a central cache (based upon APP_POOL_ID) for all "threads" (using WShell to launch non-blocking child "threads" and still share the same WinCache as the launcher, allowing simplistic, inter-process communication).
Anyway. I hope this helps somewhat.
I think, in the main, you aren't adding unnecessary env_vars to the global environment. You can keep them targetted and unique when you have more than 1.
Regards,
Richard.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…