I have a batch job that kicks off a windows service
sc serverName start serviceName
I'd like to set an environment variable for that service when I kick it off, similar to how you would do it for a subprocess. How can I do that with a windows service?
To clarify, I don't want to set any global environment variables, just one for that particular process. And I don't have access to the actual Service code.
I'dont see wich language you use, but assuming you're using C# and your class derived from ServiceBase
you have the method
protected override void OnStart(string[] args)
that contains your params in the string array. So starting your service with
sc serverName start serviceName param1 param2
will do the job.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With