场景是通过深信服sslvpn拨号登陆后,启动华为云桌面客户端,但是因为流程上有两个客户端 领导操作上不方便  本人小白一枚,想借宝地一问各位大拿,如何在现有代码基础上实现如下需求,请不吝赐教  1. 启动sslvpn客户端 (进程为a.exe)
 
  2. 启动华为客户端 (进程为b.exe)  3. 当检测到进程c.exe运行了,结束b.exe
 
  4. 当检测到进程c.exe结束了,结束a.exe 整个过程如上,目前代码实现了1和2两个步骤
  dim wsh
set wsh=Wscript.createobject("wscript.shell")wsh.exec "C:\Program Files (x86)\Sangfor\SSL\SangforCSClient\SangforCSClient.exe"
'执行ping检测
succCount=0'尝试检查网络连通情况的次数
retrytimes=500'当有一次能ping通则认为网络是通的
While succCount < 1 and retrytimes > 0
set objwmi=GetObject("winmgmts:\\.\root\cimv2")
set objitems=objwmi.ExecQuery("select * from Win32_PingStatus where Address='192.168.1.100'")
for each objitem in objitems
if objitem.statuscode = 0 then
succCount=succCount+1
end if
'wscript.sleep(30)
retrytimes=retrytimes-1
next
wendif succCount>0 then
wsh.exec "C:\Program Files (x86)\Huawei\HDPClient\CloudClient.exe"
else
wscript.echo "打开桌面客户端失败!"
end if 

解决方案 »

  1.   


    Set objwmi = getobject("winmgmts:\\.\root\cimv2")
    Set shell = createobject("wscript.shell")shell.exec "notepad.exe" ' A.EXE
    shell.exec "mspaint.exe" ' B.EXEDo
    Set colitems = objwmi.execquery("select * from win32_process where name='cmd.exe'") ' C.EXE
    If colitems.count > 0 Then
    Set colitems = objwmi.execquery("select * from win32_process where name='notepad.exe'")
    For Each objitem In colitems
    objitem.terminate()
    Next
    Exit Do
    End If
    wscript.sleep 500
    LoopDo
    Set colitems = objwmi.execquery("select * from win32_process where name='cmd.exe'")
    If colitems.count = 0 Then
    Set colitems = objwmi.execquery("select * from win32_process where name='mspaint.exe'")
    For Each objitem In colitems
    objitem.terminate()
    Next
    Exit Do
    End If
    wscript.sleep 500
    Loopmsgbox "done!"