C#程序刪除自身及所在目錄
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace killself
{
class Program
{
static void Main(string[] args)
{
BeginKillSelf();
}
[DllImport("kernel32.dll")]
public static extern uint WinExec(string lpCmdLine, uint uCmdShow);
private static void BeginKillSelf()
{
string vBatFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\a.bat";
using (StreamWriter vStreamWriter = new StreamWriter(vBatFile, false, Encoding.Default))
{
vStreamWriter.Write(string.Format(
":del\r\n" +
" del \"{0}\"\r\n" +
"if exist \"{0}\" goto del\r\n" +
"del %0\r\n", Application.ExecutablePath));
}
WinExec(vBatFile, 0);
Process.GetCurrentProcess().Kill();
Environment.Exit(0);
}
}
}
該文章在 2021/7/1 14:58:28 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |