在vb中,怎样让程序退出后删除自身?

在vb中,怎样让程序退出后删除自身?,第1张

1,用BAT文件\x0d\x0aPrivate Sub Form_Load()\x0d\x0a\x0d\x0aOpen App.Path &"\a.bat" For Output As #1\x0d\x0a'"@echo off" 不显示执行过程\x0d\x0aPrint #1, "@echo off"\x0d\x0aPrint #1, "sleep 100"\x0d\x0a'a.bat 删除指定文件\x0d\x0aPrint #1, "del " &App.EXEName + ".exe"\x0d\x0a'a.bat 删除握亏空自身\x0d\x0aPrint #1, "del a.bat"\x0d\x0aPrint #1, "cls"\x0d\x0aPrint #1, "exit"\x0d\x0aClose #1\x0d\x0a\x0d\x0aShell App.Path &"\空兆a.bat", vbHide\x0d\x0aEnd\x0d\x0a\x0d\x0aEnd Sub\x0d\x0a\x0d\x0a2、用API\x0d\x0a一个模块,非原创(我修改部分代码),可以让程序退出后自毁(删除自身)。\x0d\x0a原理还特别不清楚,不过应该和CMD的DEL命令有关,但删除时没看到CMD.EXE进程,速段瞎度也很快\x0d\x0a成功率挺高的(我还没失败过)\x0d\x0a\x0d\x0a创建一个模块,写入代码:\x0d\x0aConst NORMAL_PRIORITY_CLASS = &H20\x0d\x0aConst REALTIME_PRIORITY_CLASS = &H100\x0d\x0aConst THREAD_PRIORITY_NORMAL = 0\x0d\x0aConst THREAD_PRIORITY_IDLE = -15\x0d\x0aConst IDLE_PRIORITY_CLASS = &H40\x0d\x0aConst DETACHED_PROCESS = &H8\x0d\x0aConst CREATE_SUSPENDED = &H4\x0d\x0aConst THREAD_PRIORITY_TIME_CRITICAL = 15\x0d\x0aConst SW_HIDE = 0\x0d\x0aConst STARTF_USESHOWWINDOW = &H1\x0d\x0a\x0d\x0aType STARTUPINFO\x0d\x0acb As Long\x0d\x0alpReserved As String\x0d\x0alpDesktop As String\x0d\x0alpTitle As String\x0d\x0adwX As Long\x0d\x0adwY As Long\x0d\x0adwXSize As Long\x0d\x0adwYSize As Long\x0d\x0adwXCountChars As Long\x0d\x0adwYCountChars As Long\x0d\x0adwFillAttribute As Long\x0d\x0adwFlags As Long\x0d\x0awShowWindow As Integer\x0d\x0acbReserved2 As Integer\x0d\x0alpReserved2 As Long\x0d\x0ahStdInput As Long\x0d\x0ahStdOutput As Long\x0d\x0ahStdError As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aType PROCESS_INFORMATION\x0d\x0ahProcess As Long\x0d\x0ahThread As Long\x0d\x0adwProcessId As Long\x0d\x0adwThreadId As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aType SECURITY_ATTRIBUTES\x0d\x0anLength As Long\x0d\x0alpSecurityDescriptor As Long\x0d\x0abInheritHandle As Long\x0d\x0aEnd Type\x0d\x0a\x0d\x0aDeclare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long\x0d\x0aDeclare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long\x0d\x0aDeclare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long\x0d\x0aDeclare Function GetCurrentProcess Lib "kernel32" () As Long\x0d\x0aDeclare Function GetCurrentThreadId Lib "kernel32" () As Long\x0d\x0aDeclare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long\x0d\x0aDeclare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long\x0d\x0aDeclare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long\x0d\x0aDeclare Function GetCurrentThread Lib "kernel32" () As Long\x0d\x0aDeclare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long\x0d\x0a\x0d\x0aFunction DeleteMe() As Boolean\x0d\x0aDim szModuleAs String\x0d\x0aDim szComspec As String\x0d\x0aDim szParamsAs String\x0d\x0a\x0d\x0aDim si As STARTUPINFO\x0d\x0aDim pi As PROCESS_INFORMATION\x0d\x0aDim sa1 As SECURITY_ATTRIBUTES\x0d\x0aDim sa2 As SECURITY_ATTRIBUTES\x0d\x0a\x0d\x0aszModule = String(512, 0)\x0d\x0aszComspec = String(512, 0)\x0d\x0aszParams = String(512, 0)\x0d\x0a\x0d\x0a'// get file path names:\x0d\x0aIf ((GetModuleFileName(0, szModule, 512) 0) And (GetShortPathName(szModule, szModule, 512) 0) And (GetEnvironmentVariable("COMSPEC", szComspec, 512) 0)) Then\x0d\x0a'// set command shell parameters\x0d\x0aszComspec = Left(szComspec, InStr(szComspec, Chr(0)) - 1)\x0d\x0aszModule = Left(szModule, InStr(szModule, Chr(0)) - 1)\x0d\x0a\x0d\x0aszComspec = szComspec &" /c del " &"""" &szModule &"""" '这里是我(yfdyh000)修改的,支持带空格路径\x0d\x0a'szComspec = szComspec &" /c del " &szModule'原代码\x0d\x0a\x0d\x0a'// set struct members\x0d\x0aWith si\x0d\x0a.cb = Len(si)\x0d\x0a.dwFlags = STARTF_USESHOWWINDOW\x0d\x0a.wShowWindow = SW_HIDE\x0d\x0aEnd With\x0d\x0a'// increase resource allocation to program\x0d\x0aCall SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)\x0d\x0a\x0d\x0a'// invoke command shell\x0d\x0a'Debug.Print CreateProcess(vbNullString, szComspec, sa1, sa2, 0&, CREATE_SUSPENDED Or DETACHED_PROCESS, 0&, vbNullString, si, pi)\x0d\x0aIf CreateProcess(vbNullString, szComspec, sa1, sa2, 0, CREATE_SUSPENDED Or DETACHED_PROCESS, 0, vbNullString, si, pi) Then\x0d\x0a'// suppress command shell process until program exits\x0d\x0aCall SetPriorityClass(pi.hProcess, IDLE_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE)\x0d\x0a\x0d\x0a'// resume shell process with new low priority\x0d\x0aCall ResumeThread(pi.hThread)\x0d\x0a\x0d\x0a'// everything seemed to work\x0d\x0aDeleteMe = True\x0d\x0aExit Function\x0d\x0aElse '// if error, normalize allocation\x0d\x0aCall SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS)\x0d\x0aCall SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)\x0d\x0aEnd If\x0d\x0aEnd If\x0d\x0aDeleteMe = False\x0d\x0aEnd Function\x0d\x0a\x0d\x0a在程序中调用命令:DeleteMe(比如在:Form_Unload)\x0d\x0a如果返回True证明成功,退出后会自动删除自身。

     小程序要如何关闭个人信息的授权呢?具体 *** 作步骤如下:

      第一步:打开手机微信,进入微信首页,点击页面下方的“发现”,进入微信的发现页。

      第二步:进入微信的发现页后,点击“小程序”一栏后方的“>”,进入微信的小程序页面。

      第三步:进入悔誉旁小程序详情页面后,点击页面右上角的“...”,页面下方出现 *** 作功能选项虚郑,点击“设置”,进入小程序设置页面。

      第四步:进入小程序设置页面后,点击“用户信息”一栏后方的绿色开关按钮,页面提示“关闭授权后可能会影响使用小程序的碧橡部分功能......”,点击“关闭授权”。

      点击关闭授权后,小程序设置页面的用户信息后方的开关就处于关闭状态了,这样就关闭了个人信息的授权。

用BAT写一个删答猛除该程序的命令然后用COPY命令把这应用程序和和这旁喊个BAT文件和了应该可以把

你可以试下

比比如新建文本写入

delete

name.exe

保存为"aa.bat"的后缀名

然后用在建一个文本写入

copy

程序名.exe/b+aa.bat/a

name.exe

保存为1.BAT

点击1.bat出现name.exe点击它

理论上应该可以没清启桥做试验你试试看。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12557462.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存