时间:2021-05-22
vbs核心代码
Option ExplicitDim objWMIService,colProcessList,strComputerstrComputer = "."Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'excel.exe'")If colProcessList.Count>0 Then MsgBox "检测到EXCEL程序运行中,程序退出!" WScript.QuitEnd IfSet colProcessList = NothingSet objWMIService = NothingWScript.Quit当然你可以判断 winrar.exe等等
下面附一个代码,原来中文命名的,已经修改为英文命名并且正常运行了,因为时间问题,需要的朋友可以自行修改精简
'检测进程proname = "qq.exe"reName = IsProcess(proname)If reName = True Then msgbox "发现进程"ElseIf reName = False Then msgbox "没有发现进程"End If'检测进程 优化后的代码If IsProcess("qq.exe") = True Then msgbox "发现进程"Else msgbox "没有发现进程"End If'检测进程组proName_all = "qq.exe|notepad.exe"reName = IsProcessEx(proName_all)If reName = True Then msgbox "发现进程"ElseIf reName = False Then msgbox "没有发现进程"End If'检测进程组 优化后的代码If IsProcessEx("qq.exe|notepad.exe") = True Then msgbox "发现进程"Else msgbox "没有发现进程"End If'结束进程 前台执行proname = "qq.exe" Call CloseProcess(proname, 1)'结束进程 后台执行proname = "qq.exe" Call CloseProcess(proname, 0) '结束进程组 前台执行proName_all = "qq.exe|notepad.exe" Call CloseProcessEx(proName_all, 1)'结束进程组 后台执行proName_all = "qq.exe|notepad.exe" Call CloseProcessEx(proName_all, 0)'实例应用 结束进程 前台执行 10秒超时proname = "qq.exe"For i=1 to 10 Call CloseProcess(proname,1) Delay 1000 reName = IsProcess(proname) If reName = False Then Exit For End IfNextIf reName=True Then msgbox "结束进程失败"Else msgbox "结束进程成功"End If'实例应用 结束进程 前台执行 优化后的代码(直到型循环) 有些进程VBS检测不到 所以先关闭后检测Do Call CloseProcess("qq.exe",1) Delay 1000Loop While IsProcess("qq.exe")=Truemsgbox "结束进程成功"'实例应用 结束进程组 后台执行 10秒超时proName_all = "qq.exe|notepad.exe"For j=1 to 10 Call CloseProcessEx(proName_all,0) Delay 1000 reName = IsProcessEx(proName_all) If reName = False Then Exit For End IfNextIf reName=True Then msgbox "结束进程失败"Else msgbox "结束进程成功"End If'实例应用 结束进程组 后台执行 优化后的代码(直到型循环) 有些进程VBS检测不到 所以先关闭后检测Do Call CloseProcessEx( "qq.exe|notepad.exe",0) Delay 1000Loop While IsProcessEx( "qq.exe|notepad.exe")=Truemsgbox "结束进程成功"'函数 子程序部分代码'检测进程Function IsProcess(ExeName) Dim WMI, Obj, Objs,i IsProcess = False Set WMI = GetObject("WinMgmts:") Set Objs = WMI.InstancesOf("Win32_Process") For Each Obj In Objs If InStr(UCase(ExeName),UCase(Obj.Description)) <> 0 Then IsProcess = True Exit For End If Next Set Objs = Nothing Set WMI = NothingEnd Function'结束进程Sub CloseProcess(ExeName,RunMode) dim ws Set ws = createobject("Wscript.Shell") ws.run "cmd.exe /C Taskkill /f /im " & ExeName,RunMode Set ws = NothingEnd Sub'检测进程组Function IsProcessEx(ExeName) Dim WMI, Obj, Objs,ProcessName,i IsProcessEx = False Set WMI = GetObject("WinMgmts:") Set Objs = WMI.InstancesOf("Win32_Process") ProcessName=Split(ExeName,"|") For Each Obj In Objs For i=0 to UBound(ProcessName) If InStr(UCase(ProcessName(i)),UCase(Obj.Description)) <> 0 Then IsProcessEx = True Exit For End If Next Next Set Objs = Nothing Set WMI = NothingEnd Function'结束进程组Sub CloseProcessEx(ExeName,RunMode) dim ws,ProcessName,CmdCode,i ProcessName = Split(ExeName, "|") For i=0 to UBound(ProcessName) CmdCode=CmdCode & " /im " & ProcessName(i) Next Set ws = createobject("Wscript.Shell") ws.run "cmd.exe /C Taskkill /f" & CmdCode,RunMode Set ws = NothingEnd Sub好了这篇关于vbs进程判断的文章就介绍到这
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
下面是PHP中对象的继承的判断代码:
判断代码:$uuserid=$_GET['uid'];$member=array();if($uuserid){$member=C::t(
黑人必会!强制杀进程!对付杀毒软件啊'备注:vbs强制关闭程序'防止出现错误复制代码代码如下:OnErrorResumeNext'vbs代码开始--------
隔行变色有很多中方法来实现,之前我都是直接将判断代码写在程序中,今天我们来使用jQuery实现,代码奉上~jQuery代码:复制代码代码如下:$(functio
如果真判断代码.版本2.程序集窗口程序集1.子程序__启动窗口_创建完毕编辑框1.获取焦点().子程序_显示内容按钮_被单击.如果真(编辑框1.内容≠“中国队”