//指定一个文件名,写入脚本
string filename = Path.Combine(path,"killmyself.bat"); using (StreamWriter bat = new StreamWriter(filename, false, Encoding.GetEncoding("GB2312"))) { //删除指定程序,复制指定程序到指定路径 bat.WriteLine(string.Format(@" @echo off del "+ifexe+@" copy /y """+path+@"tempfileServer"+ifexe+@""" """+path+@""" """+path+ifexe+ @""" del %0 ")); // del %0 } ProcessStartInfo info = new ProcessStartInfo(filename); info.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(info); Environment.Exit(0);