使用Vbs检测某个进程!!!
使用Vbs检测某个进程,如果程序在运行则等待5分钟再检测。如果程序没运行则全盘查找自动运行。举例:现在开始检测A.exe-----程序在运行-----等待5分钟-----...
使用Vbs检测某个进程,如果程序在运行则等待5分钟再检测。如果程序没运行则全盘查找自动运行。
举例:现在开始检测A.exe-----程序在运行-----等待5分钟-----没运行-----全盘查找A.exe-----找到A.exe-----打开A.exe-----等待5分钟-----检测.......................一直循环!!!
请大侠帮帮忙!!!
如果好用绝对加分///
举例中的全盘查找能让它找到之后自动记录路径,下次启动就不需要再次全盘查找了。这样不是省系统资源吗?! 展开
举例:现在开始检测A.exe-----程序在运行-----等待5分钟-----没运行-----全盘查找A.exe-----找到A.exe-----打开A.exe-----等待5分钟-----检测.......................一直循环!!!
请大侠帮帮忙!!!
如果好用绝对加分///
举例中的全盘查找能让它找到之后自动记录路径,下次启动就不需要再次全盘查找了。这样不是省系统资源吗?! 展开
展开全部
Const exereg="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\myownexe\"
Dim exepath
const exename="thunder.exe" ’此处改为你自己的程序
Dim isrun : isrun=0
Dim fso
Set fso = CreateObject("scripting.filesystemobject")
Dim oShell
set oShell = CreateObject("wscript.Shell")
dim wmi
Set WMI=GetObject("WinMgmts:")
Do
isrun=0
Set procs=WMI.InstancesOf("Win32_Process")
For Each p In procs
If LCase(Trim(exename)) = LCase(Trim(p.name)) Then
isrun=1
exepath= p.ExecutablePath
Exit for
End If
Next
'WScript.echo isrun
If 1<>isrun Then
on error resume next
exepath= oShell.RegRead (exereg & exename)
If fso.FileExists(exepath) Then
exepath=Replace(exepath,"""")
exepath=Chr(34)&exepath&Chr(34)
oShell.Run exepath
Else
findtoexe(exename)
End If
End If
WScript.Sleep 5*60*1000
Set procs=nothing
Loop
Function findtoexe(pname)
Dim pn
pn=Trim(LCase(pname))
Set dvs=fso.Drives
For Each d In dvs
If d.DriveType=2 And d.IsReady Then TreeIt(d.Path&"\")
Next
End Function
Sub TreeIt(sPath)
On Error Resume next
Set myfso = CreateObject("Scripting.FileSystemObject")
Set Folder = myfso.GetFolder(sPath)
Set SubFolders = Folder.Subfolders
Set Files = Folder.Files
For Each F In Files
' WScript.Echo f.Path
If LCase(Trim(exename))=LCase(trim(f.name)) Then
oShell.Run f.Path
oShell.RegWrite exereg & exename,f.Path, "REG_SZ"
exit sub
End if
Next
For Each SubF In SubFolders
' WScript.Echo SubF.Path
TreeIt(SubF.path)'递归
Next
Set Folder = Nothing
Set SubFolders = Nothing
Set myfso = Nothing
End sub
‘ 话说你的悬赏分和我的劳动绝对不成比例,没办法谁让咱是编程爱好者呢
Dim exepath
const exename="thunder.exe" ’此处改为你自己的程序
Dim isrun : isrun=0
Dim fso
Set fso = CreateObject("scripting.filesystemobject")
Dim oShell
set oShell = CreateObject("wscript.Shell")
dim wmi
Set WMI=GetObject("WinMgmts:")
Do
isrun=0
Set procs=WMI.InstancesOf("Win32_Process")
For Each p In procs
If LCase(Trim(exename)) = LCase(Trim(p.name)) Then
isrun=1
exepath= p.ExecutablePath
Exit for
End If
Next
'WScript.echo isrun
If 1<>isrun Then
on error resume next
exepath= oShell.RegRead (exereg & exename)
If fso.FileExists(exepath) Then
exepath=Replace(exepath,"""")
exepath=Chr(34)&exepath&Chr(34)
oShell.Run exepath
Else
findtoexe(exename)
End If
End If
WScript.Sleep 5*60*1000
Set procs=nothing
Loop
Function findtoexe(pname)
Dim pn
pn=Trim(LCase(pname))
Set dvs=fso.Drives
For Each d In dvs
If d.DriveType=2 And d.IsReady Then TreeIt(d.Path&"\")
Next
End Function
Sub TreeIt(sPath)
On Error Resume next
Set myfso = CreateObject("Scripting.FileSystemObject")
Set Folder = myfso.GetFolder(sPath)
Set SubFolders = Folder.Subfolders
Set Files = Folder.Files
For Each F In Files
' WScript.Echo f.Path
If LCase(Trim(exename))=LCase(trim(f.name)) Then
oShell.Run f.Path
oShell.RegWrite exereg & exename,f.Path, "REG_SZ"
exit sub
End if
Next
For Each SubF In SubFolders
' WScript.Echo SubF.Path
TreeIt(SubF.path)'递归
Next
Set Folder = Nothing
Set SubFolders = Nothing
Set myfso = Nothing
End sub
‘ 话说你的悬赏分和我的劳动绝对不成比例,没办法谁让咱是编程爱好者呢
苏州神码物信智能科技
2024-08-22 广告
2024-08-22 广告
苏州神码物信智能科技有限公司专注于提供高效、智能的出入管理系统解决方案。该系统集成人脸识别、二维码扫描、RFID等先进技术,实现无接触快速通行,有效提升门禁管理效率与安全性。通过云端平台实时监控与数据分析,助力企业、园区、校园等场所优化管理...
点击进入详情页
本回答由苏州神码物信智能科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询