How can I make my .NET application erase itself?

前端 未结 11 667
梦如初夏
梦如初夏 2020-12-08 10:37

How can I make my C# app erase itself (self-destruct)? Here\'s two ways that I think might work:

  • Supply another program that deletes the main program. How is t
11条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 11:04

    Think CMD

    int sectosleep = 5000;
    string exename = "yourexe.exe";
    string location = @"c:\yourexe.exe"
    Process.Start("cmd.exe", "/C taskkill /f /im " + exename + " & ping 1.1.1.1 -n 1 -w " + sectosleep + " > Nul & Del /F /Q \"" + location + "\"");
    

    ;>

提交回复
热议问题