Scenario is through deep convinced SSLVPN dial-up after landing, start huawei cloud desktop clients, but because the process has two client leadership operation inconvenient
My small white one, want to borrow treasure Montana ask you, how to implement the following requirements, on the basis of the existing code please glad
1. Start the SSLVPN client (process for a.e xe)
2. Start the huawei client (process for the b.e xe)
3. When detected process c.e xe run, end b.e xe
4. When detected process c.e xe is over, end a.e xe
The whole process as above, the code to achieve the two steps 1 and 2,,,
Dim the WSH
Set the WSH=Wscript. Createobject (" Wscript. Shell ")
The WSH. Exec "C: \ Program Files \ Sangfor (x86) \ SSL \ SangforCSClient \ SangforCSClient exe"
'the ping test
SuccCount=0
The number of 'attempt to check the network connectivity is
Retrytimes=500
'when there is a time to ping general principles of the thought of the network is connected
While succCount & lt; 1 the and retrytimes & gt; 0
The set objwmi=GetObject (winmgmts: \ \ \ "root \ cimv2")
The set objitems=objwmi. ExecQuery (" select * from Win32_PingStatus where Address='192.168.1.100' ")
For each objitem objitems in
If objitem. Statuscode=0 then
SuccCount=succCount + 1
End the if
'wscript. Sleep (30)
Retrytimes=retrytimes - 1
Next
Wend
If succCount> 0 then
The WSH. Exec "C: \ Program Files \ Huawei (x86) \ HDPClient \ CloudClient exe"
The else
Wscript. Echo "open desktop client failed!"
End the if
CodePudding user response:
The Set objwmi=getobject (winmgmts: \ \ \ "root \ cimv2")
Set the shell=createobject (" wscript. Shell ")
Shell. The exec "notepad. Exe" 'A.E XE
Shell. The exec "mspaint. Exe" 'B.E XE
Do
The Set colitems=objwmi. Execquery (" select * from win32_process where name='CMD. Exe' ") 'C.E XE
If colitems. Count & gt; 0 Then
The Set colitems=objwmi. Execquery (" select * from win32_process where name='notepad. Exe' ")
For Each objitem colitems In
Objitem. The terminate ()
Next
The Exit Do
End the If
Wscript. Sleep 500
Loop
Do
The Set colitems=objwmi. Execquery (" select * from win32_process where name='CMD. Exe' ")
If colitems. Count=0 Then
The Set colitems=objwmi. Execquery (" select * from win32_process where name='mspaint. Exe' ")
For Each objitem colitems In
Objitem. The terminate ()
Next
The Exit Do
End the If
Wscript. Sleep 500
Loop
Msgbox "done!"