AutoBat

var currentDir = Directory.GetCurrentDirectory();
var filePath = string.Format("{0}\Auto.bat", currentDir);
if (File.Exists(filePath))
File.Delete(filePath);

var sourcePath = string.Format("{0}\ABCD.exe", currentDir);
string autoBat = "@echo off ping -n 2 127.1 >nul taskkill /f /im ABCD.Service.exe /im ABCD.exe start " + """ + "" " + """ + sourcePath + "" ";
File.WriteAllText(filePath, autoBat, Encoding.Default);

Process p = new Process();
p.StartInfo.FileName = filePath;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();

原文地址:https://www.cnblogs.com/RR-ghost/p/6419429.html