fileName : deletesel.cpp
//need head of file
#include <iostream>
using namespace std;
#include <fstream>
#include <windows.h>
#include <shellapi.h>
int main()
{
//write 1.bat file
ofstream file;
file.open("1.bat");
file <<"del deleteself.exe" <<endl;
file <<"del 1.bat" <<endl;
file.close();
//run 1.bat file
ShellExecute(NULL,"open","1.bat","",NULL,SW_HIDE);
return 0;
}
在winddow7 ,win32控制台,亲测可行!