When using a service manager like srvany or nssm to run a normal program as a service, you can set the program's environment using the registry as documented here: http://support.microsoft.com/kb/197178. When doing this, you need to set all the environment variables, not just the ones you want to change. Microsoft's article says, "Make sure to include all core entries like PATH, TEMP, OS, and so on." What exactly is included in "and so on" and is there a definitive reference for that information?
Windows – What core environment variables should be set for a Windows service
environment-variablesservicewindows
Related Topic
- Windows – How to Add a Windows Environment Variable Without Rebooting
- Linux – Check Environment Variables of a Running Process on Unix
- Windows – Can the environment variables tool in windows be launched directly
- Linux Service Command – Using Environment Variables
- Windows GPO Software Restrictions Policy not working with %TEMP% variable
- Windows – Set Apache specific Environment variables in Windows
- Windows – Where is this hidden computer name coming from
Best Answer
There's no concrete list of exactly which environment variables that you need to set. The answer is simply all the environment variables that your application/service will be using. This varies depending on the application. The particular application might only use
TEMP
, or it might not need any environment variables at all. Or it might use_NT_SYMBOL_PATH
and will crash if that environment variable is not found! There's no way to know without knowing your application.If you type
set
at the command-line, you'll be given a list of your current environment variables, which is a pretty good list to start from.Edit: If you want to see what environment variables your current Windows services are using as an example to go by, Type this into Powershell 3: