'Dim QQUIN
Set ob1_miservice = GetObject _
("Winmgmts: \" & "." & "\ root \ cimv2 ")
Set ps = ob1_miservice. ExecQuery _
("SELECT * FROM Win32_process ")
For Each ps in ps 'list all running programs in the system
'For each ps in getobject ("winmgmts: \\\\\ root \ cimv2: win32_process"). instances _' lists all running programs in the system
If LCase (ps. Name) = "qq.exe" Or LCase (ps. Name) = "tm.exe" then' check whether QQ Or TM
AppPath = ps. commandline 'extract the life line of the QQ Program
Tmp = Replace (AppPath, Chr (34), Space (1 ))
UIN1 = InStr (tmp, "QQUIN:") + 6
QQUIN = Mid (tmp, UIN1, InStr (UIN1, tmp, Space (1)-UIN1.
End If
Next
If Len (QQUIN) = 0 Then
MsgBox "the QQ or TM program is not running in the system. Please restart QQ or TM. After login, use one-click switch to QQ or TM program, and then run this script"
Else
Do 'loop detection
Myqqin = chkuin (QQUIN) 'checks whether the obtained QQ number is enabled on the local machine.
If Not myqqin Then, If Not, re-run the QQ program and log on
Runapp (AppPath )'
Wscript. sleep 10000 'Wait 10 seconds
Else
Wscript. sleep 5000 'Wait 5 seconds
End If
Loop 'returns to continue detection
End If
Function RunApp (AppPath)
Dim obj
Set obj = CreateObject ("WScript. Shell ")
Obj.exe c (AppPath)
End Function
Function chkuin (QQUIN)
Set ob1_miservice = GetObject _
("Winmgmts: \" & "." & "\ root \ cimv2 ")
Set ps = ob1_miservice. ExecQuery _
("SELECT * FROM Win32_process ")
For Each ps in ps 'list all running programs in the system
'For each ps in getobject ("winmgmts: \\\\\ root \ cimv2: win32_process"). instances _
If LCase (ps. Name) = "qq.exe" Or LCase (ps. Name) = "tm.exe" Then
AppPatht = ps. commandline
'By chenall qq 368178720
Tmp = Replace (AppPatht, Chr (34), Space (1 ))
UIN1 = InStr (tmp, "QQUIN:") + 6
QQUINTMP = Mid (tmp, UIN1, InStr (UIN1, tmp, Space (1)-UIN1)
If QQUINTMP = QQUIN Then chkuin = True End If
End If
Next
End Function