有没有程序高手能帮忙写一个超简单的关闭进程小程序?
我玩一个游戏,每次游戏打开以后,会出现一个叫Launcher.exe的进程,进入游戏以后,需要关闭这个进程才能正常进行,这个进程是游戏启动生成的,没有它又无法启动游戏,但...
我玩一个游戏,每次游戏打开以后,会出现一个叫Launcher.exe的进程,进入游戏以后,需要关闭这个进程才能正常进行,这个进程是游戏启动生成的,没有它又无法启动游戏,但游戏启动完后,该进程就没用了。每次通过进程管理器来关闭也比较麻烦,有没有高手能做一个简单的程序,只要运行一下小程序,就能关闭这个进程?
也许是我没说的太明白,通过ntsd 或者taskkill 来关闭进程,都需要查出PID来,但是每次进程的PID都不是一样的。所以这样更麻烦,还不如在任务管理器直接关闭进程呢。至于 shuqiyi1987 提供的方法。。。。我根本就看不懂啊。该怎么使用都不知道。 展开
也许是我没说的太明白,通过ntsd 或者taskkill 来关闭进程,都需要查出PID来,但是每次进程的PID都不是一样的。所以这样更麻烦,还不如在任务管理器直接关闭进程呢。至于 shuqiyi1987 提供的方法。。。。我根本就看不懂啊。该怎么使用都不知道。 展开
7个回答
展开全部
'2、代码粘贴以下代码到代码页
Option Explicit
'相关函数声明,其作用可以查相关WIN API手册
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwsize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH '程序的名字
End Type
Const TH32CS_SNAPheaplist = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPthread = &H4
Const TH32CS_SNAPmodule = &H8
Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Dim StarTime '程序开始运行时的时间
Dim StopTime '程序停止运行时的时间
Dim ExeName As String '程序名
Dim CTime As Long '记录开始到停止所经过的秒数
Private Sub Command1_Click() '单击开始后激活timer1开始监测
Timer1.Enabled = True '激活timer1
Timer1.Interval = 10 '每十毫秒监测一次
Text1.Enabled = False '设置text1不响应
End Sub
Private Sub Command2_Click() '单击停止后timer1停止监测,timer2停止计时
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 1000 '1000毫秒=1秒,即
Text1.Enabled = True '设置text1可响应
End Sub
Private Sub form_Load() '初始化
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 1000
Command1.Caption = "开始!"
Command2.Caption = "停止!"
Text1.Enabled = True
Text1 = "三国.exe"
End Sub
Private Sub Timer1_Timer() '监测
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim mSnapshot As Long
Dim hSnapshot As Long
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程快照的句柄
Proc.dwsize = Len(Proc)
lPid = ProcessFirst(hSnapshot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
If InStr(1, Proc.szExeFile, Text1, vbTextCompare) Then '判断指定程序是否执行
StarTime = Time '记录当前时间到变量
Timer1.Enabled = False 'timer1停止监测
Timer1.Interval = 10
Timer2.Enabled = True 'timer2开始计时
Timer2.Interval = 1000
End If
lPid = ProcessNext(hSnapshot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapshot '关闭进程快照句柄
End Sub
Private Sub Timer2_Timer() '计时
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim mSnapshot As Long
Dim hSnapshot As Long
Dim LTime As String
Dim IsStop As Boolean
IsStop = True
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程快照的句柄
Proc.dwsize = Len(Proc)
lPid = ProcessFirst(hSnapshot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
CTime = CTime + 1 '每次累加一秒
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
If InStr(1, Proc.szExeFile, Text1, vbTextCompare) Then IsStop = False '判断指定程序是否停止执行
lPid = ProcessNext(hSnapshot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapshot '关闭进程快照句柄
If IsStop = True Then
StopTime = Time '记录程序结束的时间
Timer2.Enabled = False 'timer2停止计时
Timer2.Interval = 1000
LTime = sToTime(CTime) '调用sToTime函数将秒数转为:“天:时:分:秒”的格式
CTime = 0
Text1.Enabled = True
Open "C:\记录.txt" For Output As #1
Print #1, "学号:" & Text2
Print #1, "开始时间:" & Format(StarTime, "dd号hh时nn分ss秒") 'Print方法向文件写入数据,下同
Print #1, "停止时间:" & Format(StopTime, "dd号hh时nn分ss秒")
Print #1, "时间差:" & LTime
Close
End If
End Sub
Private Function sToTime(InTime As Long) As String '将秒数转为:“天:时:分:秒”的格式,返回字符型
Dim TDay As Integer
Dim THous As Integer
Dim TSCN As Integer
Dim TS As Integer
TDay = 0
THous = 0
TSCN = 0
TS = 0
If (InTime / 60 / 60 / 24) > 0 Then TDay = InTime / 60 / 60 / 24 '如果大于一天,则计算有几天,以下类推
If (InTime / 60 / 60) > 0 Then THous = InTime / 60 / 60 '如果大于一小时
If (InTime / 60) > 0 Then TSCN = InTime / 60 '如果大于一分
If InTime < 60 Then TS = InTime '如果小于60秒
sToTime = TDay & "天" & THous & "时" & TSCN & "分" & TS & "秒"
End Function
Option Explicit
'相关函数声明,其作用可以查相关WIN API手册
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwsize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH '程序的名字
End Type
Const TH32CS_SNAPheaplist = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPthread = &H4
Const TH32CS_SNAPmodule = &H8
Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Dim StarTime '程序开始运行时的时间
Dim StopTime '程序停止运行时的时间
Dim ExeName As String '程序名
Dim CTime As Long '记录开始到停止所经过的秒数
Private Sub Command1_Click() '单击开始后激活timer1开始监测
Timer1.Enabled = True '激活timer1
Timer1.Interval = 10 '每十毫秒监测一次
Text1.Enabled = False '设置text1不响应
End Sub
Private Sub Command2_Click() '单击停止后timer1停止监测,timer2停止计时
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 1000 '1000毫秒=1秒,即
Text1.Enabled = True '设置text1可响应
End Sub
Private Sub form_Load() '初始化
Timer1.Enabled = False
Timer1.Interval = 10
Timer2.Enabled = False
Timer2.Interval = 1000
Command1.Caption = "开始!"
Command2.Caption = "停止!"
Text1.Enabled = True
Text1 = "三国.exe"
End Sub
Private Sub Timer1_Timer() '监测
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim mSnapshot As Long
Dim hSnapshot As Long
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程快照的句柄
Proc.dwsize = Len(Proc)
lPid = ProcessFirst(hSnapshot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
If InStr(1, Proc.szExeFile, Text1, vbTextCompare) Then '判断指定程序是否执行
StarTime = Time '记录当前时间到变量
Timer1.Enabled = False 'timer1停止监测
Timer1.Interval = 10
Timer2.Enabled = True 'timer2开始计时
Timer2.Interval = 1000
End If
lPid = ProcessNext(hSnapshot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapshot '关闭进程快照句柄
End Sub
Private Sub Timer2_Timer() '计时
Dim i As Long, lPid As Long
Dim Proc As PROCESSENTRY32
Dim mSnapshot As Long
Dim hSnapshot As Long
Dim LTime As String
Dim IsStop As Boolean
IsStop = True
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程快照的句柄
Proc.dwsize = Len(Proc)
lPid = ProcessFirst(hSnapshot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据
CTime = CTime + 1 '每次累加一秒
Do While lPid <> 0 '当返回值非零时继续获取下一个进程
If InStr(1, Proc.szExeFile, Text1, vbTextCompare) Then IsStop = False '判断指定程序是否停止执行
lPid = ProcessNext(hSnapshot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据
Loop
CloseHandle hSnapshot '关闭进程快照句柄
If IsStop = True Then
StopTime = Time '记录程序结束的时间
Timer2.Enabled = False 'timer2停止计时
Timer2.Interval = 1000
LTime = sToTime(CTime) '调用sToTime函数将秒数转为:“天:时:分:秒”的格式
CTime = 0
Text1.Enabled = True
Open "C:\记录.txt" For Output As #1
Print #1, "学号:" & Text2
Print #1, "开始时间:" & Format(StarTime, "dd号hh时nn分ss秒") 'Print方法向文件写入数据,下同
Print #1, "停止时间:" & Format(StopTime, "dd号hh时nn分ss秒")
Print #1, "时间差:" & LTime
Close
End If
End Sub
Private Function sToTime(InTime As Long) As String '将秒数转为:“天:时:分:秒”的格式,返回字符型
Dim TDay As Integer
Dim THous As Integer
Dim TSCN As Integer
Dim TS As Integer
TDay = 0
THous = 0
TSCN = 0
TS = 0
If (InTime / 60 / 60 / 24) > 0 Then TDay = InTime / 60 / 60 / 24 '如果大于一天,则计算有几天,以下类推
If (InTime / 60 / 60) > 0 Then THous = InTime / 60 / 60 '如果大于一小时
If (InTime / 60) > 0 Then TSCN = InTime / 60 '如果大于一分
If InTime < 60 Then TS = InTime '如果小于60秒
sToTime = TDay & "天" & THous & "时" & TSCN & "分" & TS & "秒"
End Function
展开全部
ntsd -c q -p PID(PID是进程ID,可以通过任务管理器-查看-选择列-把PID打勾;然后就能在任务管理起看到你这个进程的ID了)
把这段放在一个文本中,保存,再修改文本后缀名为.bat!! 每次需要直接双击就可以了,是个小脚本
把这段放在一个文本中,保存,再修改文本后缀名为.bat!! 每次需要直接双击就可以了,是个小脚本
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用批处理吧
新建个文本文件,写入
ntsd -c q -p 要关闭进程的PID
保存为bat后缀的文件
其中要关闭进程,也就是你说的Launcher.exe的PID在任务管理器里面可以看见
没有的话点查看——选择列——进程PID打钩就可以看见了
希望能帮到你
新建个文本文件,写入
ntsd -c q -p 要关闭进程的PID
保存为bat后缀的文件
其中要关闭进程,也就是你说的Launcher.exe的PID在任务管理器里面可以看见
没有的话点查看——选择列——进程PID打钩就可以看见了
希望能帮到你
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
保存下面这行代码为.bat文件,双击即可关闭进程Launcher.exe:
ntsd -c q -pn Launcher.exe
————————
用ntsd而不用taskkill的原因是:
1、ntsd比taskkill权力大,能关闭更多的进程
2、taskkill.exe在Windows XP Home Edition及以下的系统裏是没有的
ntsd -c q -pn Launcher.exe
————————
用ntsd而不用taskkill的原因是:
1、ntsd比taskkill权力大,能关闭更多的进程
2、taskkill.exe在Windows XP Home Edition及以下的系统裏是没有的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
同时按下CTRL+ALT+DEL然后点结束进程
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询