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\r\nping -n 2 127.1 >nul\r\ntaskkill /f /im ABCD.Service.exe /im ABCD.exe\r\nstart " + "\"" + "\" " + "\"" + sourcePath + "\"\r\n";
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();

posted @ 2017-02-20 14:36  RR幻影  Views(261)  Comments(0Edit  收藏  举报