On 2020-12-31, Bill Stewart wrote: > cygrunsrv --help shows this: > > -e, --env <VAR=VALUE> Optional environment strings which are added > to the environment when service is started. You can add up to 255 > environment strings using the `--env' option.
I made experiment few minutes ago (was curious to pass as many options as possible): cygrunsrv -I mysrv -t manual -p $PWD/srv.exe -c $PWD -e MY=hello -d "My Srv" -f "Testing Cyg Service" and didn't see "MY" in the list of env vars of actual running processes... > These are added as REG_SZ values in > HKLM\SYSTEM\CurrentControlSet\Services\<servicename>\Parameters\Environment > registry subkey. Right: ls /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/mysrv/Parameters/Environment MY cat /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/mysrv/Parameters/Environment/MY | strings hello There is: https://web.archive.org/web/20100306183453/http://support.microsoft.com/kb/821761 Changes that you make to environment variables do not affect services that run under the Local System account until you restart Windows. but I'm not sure that has effect: This behavior occurs because services that run under the Local System account inherit their environment from the Services.exe process. The Services.exe process receives the environment settings for the Local System account when Windows starts. because SYSTEM/CurrentControlSet/Services is something different... Haven't tried to reboot... For my purpose (ensuring that env var CYGWIN is propagated into every possible running executable) `-e` is not necessary as `cygrunsrv` inherits CYGWIN from `SYSTEM\CurrentControlSet\Control\Session Manager\Environment`. But strangely it is not passed to controlled process (like exim)... -- http://defun.work/ -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple