怎么让一个程序运行时自动打开另一个程序

来源:百度知道 编辑:UC知道 时间:2024/07/02 02:07:37
请教各位电脑高手:如何实现 一个程序运行时自动打开另一个程序(例如:我打开A.EXE的时候 B.EXE随着A.EXE的打开而打开)

下面代码复制到记事本,保存为后缀名为VBS的脚本文件,然后运行。

当notepad.exe(记事本)运行时,calc.exe(计算器)就运行。(你改为你自己的程序A和程序B就行了。但是现在还有bug,如果notepad在运行,calc就算被关了也还是会运行,稍后再帮你修改一下)

checkProcess = "notepad.exe" '监控的程序
startProcess = "calc.exe" '要运行的程序
startProcessPath = "%SystemRoot%\system32\calc.exe" '要运行的程序的路径

set os = Wscript.CreateObject("Wscript.shell")
do
processOne = false
processTwo = false
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2:win32_process").instances_
for each process in objWMIService
if process.name = checkProcess then processOne = True
if process.name = startProcess then processTwo = True
next
if processOne = True and processTwo = false then
os.run startProcessPath
end if
wscript.sleep 500
loop

把两个程序捆绑起来!网上有工具!自己找!