Setting environment variable for Windows service
I have a batch job that starts a windows service
sc serverName start serviceName
I would like to set an environment variable for this service when I unsubscribe, similar to how you would for a subprocess. How can I do this using a windows service?
To clarify, I don't want to set global environment variables, just one for this particular process. And I don't have access to the actual service code.
+3
source to share
1 answer
I don't see which language you are using, but if you are using C # and your class derived from ServiceBase
you have a method
protected override void OnStart(string[] args)
which contains your parameters in an array of strings. So start your service with
sc serverName start serviceName param1 param2
will do the job.
+1
source to share