服务安装
//开启服务
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string installUtil = "InstallUtil.exe";
//卸载服务
string ins = $"\"{InstallationPath}\\{installUtil}\" /u \"{InstallationPath}\\{service}.exe \"";
p.StandardInput.WriteLine(ins);
bool result = false;
int tryTimes = 0;
REINSTALL:
//重新安装服务
ins = $"\"{InstallationPath}\\{installUtil}\" \"{InstallationPath}\\{ServiceNames}.exe \"";
p.StandardInput.WriteLine(ins);
p.StandardInput.WriteLine(" sc config ServiceName1 start=auto");//配置自动启动