We have a windows service application. When we install the service, we pass in command line arguments to capture some values that are used by the service. As an example, here -r is used to identify that it is an install.
MyService.exe -r /url=value1 /time=value2
These values are stored in the local registry.
Now we want these values to be configurable. i.e, when we stop and start the service, we should be able to do something like (-s to identify start of the service)
MyService.exe -s /time=newvalue
Now, is it possible to read this new value from the command line?.
Assuming that your entry point for the EXE looks something like
static void Main(string args)
You can just use the
args array which has all the command line arguments as an array.
If you don't/can't get it in the entry point, you can use
string args = Environment.GetCommandLineArgs();
to get the command line arguments.