VBS uses the QQ or TM Automatic Logon code and prevents scripts from being closed.

Source: Internet
Author: User

'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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.