我目前正在尝试实现一个运行特殊命令的服务,该命令对传递的参数执行某些操作,例如:文件路径。我正在使用cmd
命令:
sc control "ServiceName" 128
但是,这个命令没有为我提供任何输入参数的方法。方法如下:
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;
}
}
我可以输入的唯一参数是int
command
for 方法。我想输入一个folder path
for t1.readLog();
。在上面的代码中,我必须对不灵活且麻烦的路径进行硬编码。那么,有没有办法解决这个问题?