76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
|
// SelfDel.cpp : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨Ӧ<CCA8>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ㡣
|
|||
|
//
|
|||
|
|
|||
|
#include "stdafx.h"
|
|||
|
#include <Windows.h>
|
|||
|
|
|||
|
|
|||
|
int _tmain(int argc, _TCHAR* argv[])
|
|||
|
{
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD>ⰴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>!!!\n");
|
|||
|
system("pause");
|
|||
|
|
|||
|
char szFileName[MAX_PATH] = {0};
|
|||
|
char szCmdFileName[MAX_PATH] = {0};
|
|||
|
char szCmd[MAX_PATH] = {0};
|
|||
|
char szBat[MAX_PATH] = {0};
|
|||
|
int iTime = 5;
|
|||
|
/*
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
1. <EFBFBD><EFBFBD>ʱ5<EFBFBD><EFBFBD>
|
|||
|
2. ɾ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
3. ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
@echo off
|
|||
|
choice /t 5 /d y /n >nul
|
|||
|
del C:\Users\DemonGan\Desktop\SelfDel\Debug\SelfDel.exe
|
|||
|
del %0
|
|||
|
*/
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
|||
|
::GetModuleFileName(NULL, szFileName, MAX_PATH);
|
|||
|
::lstrcpy(szCmdFileName, szFileName);
|
|||
|
char *p = ::strrchr(szCmdFileName, '\\');
|
|||
|
p[0] = '\0';
|
|||
|
::lstrcat(szCmdFileName, "\\selfdel.bat");
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
::wsprintf(szBat, "@echo off\nchoice /t %d /d y /n >nul\ndel %s\ndel %%0\n", iTime, szFileName);
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
FILE *fp = NULL;
|
|||
|
fopen_s(&fp, szCmdFileName, "w+");
|
|||
|
if (NULL == fp)
|
|||
|
{
|
|||
|
return 1;
|
|||
|
}
|
|||
|
fwrite(szBat, (1 + ::lstrlen(szBat)), 1, fp);
|
|||
|
fclose(fp);
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
::wsprintf(szCmd, "cmd.exe /c call %s", szCmdFileName);
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>µĽ<C2B5><C4BD>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD>̨<EFBFBD>ķ<EFBFBD>ʽִ<CABD><D6B4>cmd<6D><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
STARTUPINFO si = { 0 };
|
|||
|
PROCESS_INFORMATION pi;
|
|||
|
si.cb = sizeof(si);
|
|||
|
si.dwFlags = STARTF_USESHOWWINDOW;//ָ<><D6B8>wShowWindow<6F><77>Ա<E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