I am currently trying to implement a service that runs a special command that does something with arguments passed, for example: file paths. I am using the cmd
command:
sc control "ServiceName" 128
However, this command doesn't provide any way for me to input arguments. The method is as below:
protected override void OnCustomCommand(int command)
{
switch(command)
{
case 128:
Command.StartProcess(3);
LogWriter.WriteLog("Next output: ");
Command.StartProcess(4);
break;
case 129:
// input extension, output extension, key id , working path
try
{
test t1 = new test();
t1.readLog(@"C:\Users\Joe\Desktop\success.txt");
LogWriter.WriteLog(t1.input);
LogWriter.WriteLog(t1.output);
}
catch(Exception e)
{
LogWriter.WriteLog(e.ToString());
}
finally { LogWriter.WriteLog("abc"); }
//LogWriter.WriteLog(t1.output + "def");
break;
}
}
The only argument i can input is the int
command
for the method. I would like to input a folder path
for t1.readLog();
. In the above code, I have to hard code the path which isn't flexible and troublesome. So, is there anyway to work this out?