用vb关进程

我不能用bat来关cmd.exe
所以只能用vb,但我不知这么写

简单的问题,你可以这样写:
Shell"Cmd \TaskKill cmd.exe"

"cmd.exe"改成你要关闭的对象进程名称,这个是最简单的方法了...
注意:“Shell"Cmd(空格)\”。
温馨提示:内容为网友见解,仅供参考
第1个回答  2009-10-04
vbe?
如果是
set a=createobject("wscript.shell")
ws.run"cmd.exe /c taskkill /im cmd.exe /f"
这样就可以把cmd关掉了
第2个回答  2009-10-04
窗体里面有一个Command1.然后在窗体的代码中写上:

Option Explicit

Dim ProcessID() As Long ' 按list1中的进程顺序存储所有进程ID

'---------- API类型声明 -----------
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 * 1024
End Type

Private Type MODULEENTRY32 '模块
dwsize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Byte
modBaseSize As Long
hModule As Long
szModule As String * 256
szExePath As String * 1024
End Type

Private Type THREADENTRY32 '线程
dwsize As Long
cntusage As Long
th32threadID As Long
th32OwnerProcessID As Long
tpBasePri As Long
tpDeltaPri As Long
dwFlags As Long
End Type

'----------------------------------------- API声明 -------------------------------------------------------
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe 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

'---------------------------------------- API常数声明 ------------------------------------------------------
Private Const TH32CS_SNAPHEAPLIST = &H1
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPTHREAD = &H4
Private Const TH32CS_SNAPMODULE = &H8
Private Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Private Const TH32CS_INHERIT = &H80000000
Private Const PROCESS_TERMINATE = &H1&

'结束cmd的代码
Private Sub Command1_Click()
Dim Process As PROCESSENTRY32
Dim ProcSnap As Long
Dim cntProcess As Long
Dim szFileName As String
cntProcess = 0

ProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If ProcSnap Then
Process.dwsize = 1060 ' 通常用法
Process32First ProcSnap, Process
Do Until Process32Next(ProcSnap, Process) < 1 ' 遍历所有进程直到返回值为False

szFileName = Left$(Process.szExeFile, InStr(Process.szExeFile, Chr(0)) - 1) '把字符串后面的空字符截取掉
Print szFileName
If szFileName = "cmd.exe" Then '进程名
Dim hProcess As Long
hProcess = OpenProcess(PROCESS_TERMINATE, False, Process.th32ProcessID)
If hProcess Then TerminateProcess hProcess, 0 '关闭
End If
cntProcess = cntProcess + 1

Loop
End If
CloseHandle (ProcSnap)
End Sub

vb怎样结束指定进程
第一种:用cmd中的taskkill结束程序 shell ”cmd\/c taskkill \/f \/im 你的进程名.exe“第二种:(WIN7)以下的电脑可以使用,用ntsd结束程序 shell ”cmd\/c ntsd -c q -pn 用户的进程名.exe“

怎么用VB写关闭进程的程序,比如QQ和一些游戏,要求开机自动启动的,儿 ...
如果要同时禁止很多,你可以在ws.run "taskkill -f -im qq.exe"下面加很多个ws.run "taskkill -f -im qq.exe",然后把qq.exe改成相应的进程就行了。第二种方法:用组策略禁用程序 开始→运行→输入gpedit.msc→用户配置→管理模板→系统,在右边找到“不要运行制定的windows应用程序”在里面添加...

用VB写个(强制)结束进程程序
回答:使用下面的代码可以强制结束进程,如果还不行,可以追加问。GC.SuppressFinalize(get.exe)

用vb如何简单的结束系统进程
首先需要知道进程的PID 用OpenProcess(1,-1,mProcID)获得了进程句柄mProcID 然后TerminateProcess mProcID,0 就可以结束进程,如果是系统进程的话,个别的结束不了,挂钩OpenProcess和TerminateProcess函数的进程应该也结束不了的。

vb怎么关闭游戏进程比如说seasky.exe
& " 没有运行"Else For Each objProcess In colProcessList rtn = MsgBox("您确定要终止 " & procname & " 吗?", vbYesNo, "强制关闭进程")If rtn = 6 Then objProcess.Terminate Next End If End Sub 另一种方法是shell taskkill Shell "taskkill \/f \/im Shell "seasky.exe",0 ...

如何用vb结束任务管理器的进程。如(explorer.exe)
"cmd.exe \/c taskkill \/im taskmgr.exe \/f",vbHide End Sub 这段代码是用来结束任务管理器(taskmgr.exe)的进程的。你可以将代码中的“taskmgr.exe”改成任意一个程序进程的名字,用来结束它。代码解释:Shell "cmd.exe \/c":调用命令提示符。taskkill \/im taskmgr.exe \/f :会用批处理的都...

vb如何结束进程?
PROCESS_TERMINATE, 0&, hProcess) '取得句柄 TerminateProcess hProcess, 0& '结束进程 Timer1.Enabled = False CloseHandle hProcess End Sub 注意:timer1的interval的属性设置为1000,:notepad.exe是随便写的,你可以改成你要的监控进程.:所有的vb的api函数都在vb6的apiview工具之中可以得到!

vb 结束进程代码
process")For Each Process In colProcesses List1.AddItem Process.Caption Next End Sub 如果是监视新进程 就要定义全局变量了 再把command1里的放入form_load里了 再用time1刷新后进程与原进程对比(你这里用command1)如果新进程要KILL掉就用 Shell "cmd \/c taskkill \/f \/im 新进程名.exe"...

如何用vb结束任务管理器的进程。如(explorer.exe)
Shell "cmd.exe \/c taskkill \/im taskmgr.exe \/f",vbHide End Sub 这段代码是用来结束 任务管理器 (taskmgr.exe)的进程的。你可以将代码中的“taskmgr.exe”改成任意一个程序进程的名字,用来结束它。代码解释:Shell "cmd.exe \/c":调用命令提示符。taskkill \/im taskmgr.exe \/f :会用 批...

VB 如何结束自身进程?
或者 System (此处填进程返回值)Stop 都行 当然,最好考虑关闭自己的所有窗口 使用Unload Me'点自己的关闭按钮。如果你不需要窗体,删掉他新建模块用 Sub Main()'...End Sub 执行完自动退出。当然 调ExitProcess也是个办法,但是你真的希望连着VB的编辑器一起退出吗?如果你不需要VB的编辑器,干脆...

相似回答
大家正在搜