using System; using System.Windows.Forms; using System.Diagnostics; using System.IO; public class MyForm : Form { [STAThread] static void Main() { Application.Run(new MyForm()); } // ================================================================================== public MyForm() { Button button=new Button(); button.SetBounds(20,20,100,100); this.Controls.Add(button); button.Click+=(o,e)=>{ cheat(); }; } // ================================================================================== protected override void OnActivated(EventArgs e) { bool automatic = false; // === true にすると、立ち上げただけで実行!!! if (automatic) { cheat(); } } // ================================================================================== private void cheat() { string exeFile = "selfdeleting.exe", // === c#-exe ; 作成するファイル名を設定!!! assistantFile = "assistant.vbs"; // === vbs to be created temporarily !!! // ################################################# // === if you want to do some 'work', do here !!! // ################################################# // === create an assistant file and write into !!! StreamWriter vbs = new StreamWriter(assistantFile); vbs.WriteLine("Dim wait"); // in the file dim two variables vbs.WriteLine("Dim fso"); // wait 5 seconds vbs.WriteLine("wait = dateadd(\"s\",5,now)"); vbs.WriteLine("do until now > wait"); vbs.WriteLine("loop"); // use scripting object vbs.WriteLine("Set fso = CreateObject(\"Scripting.FileSystemObject\")"); vbs.WriteLine("fso.DeleteFile(\""+exeFile+"\")"); vbs.WriteLine("fso.DeleteFile(\""+assistantFile+"\")"); // close the StreamWriter vbs.Flush(); vbs.Close(); // === vbs file of content like the following will be made !!! /* Dim wait Dim fso wait = dateadd("s",5,now) do until now > wait loop Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFile("selfdeleting.exe") // === depends the name !!! fso.DeleteFile("assistant.vbs") */ // === launch the vb script('assistant') file !!! Process myProcess = new Process(); myProcess.StartInfo.FileName = assistantFile; myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; myProcess.Start(); // === vbs process is activated, and in a short time, // kills ***.exe and assistant files, and process ends!!! this.Close(); } // ================================================================================== } // ######################################################################################