VBS takes the QQ or TM automatic login code and prevents the script from being closed _vbs

Source: Internet
Author: User
Tags sleep
' Dim Qquin
Set objWMIService = GetObject _
("Winmgmts:\\" & "." & "\root\cimv2")
Set PS = objWMIService.ExecQuery _
("SELECT * from Win32_Process")
For every PS in PS ' lists all running programs in the system

' For every 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 ' detects whether QQ or TM
AppPath = Ps.commandline ' Extract QQ program's Life Line
TMP = Replace (AppPath, CHR, Space (1))
UIN1 = INSTR (tmp, "Qquin:") + 6
Qquin = Mid (tmp, UIN1, INSTR (UIN1, TMP, Space (1))-UIN1) ' Take the QQ number.
End If
Next
If Len (Qquin) = 0 Then
MsgBox "The system does not run QQ or TM program, please restart QQ or TM, after landing use a key switch to the QQ or TM program, and then run this script"
Else
Do ' Loop detection
Myqqin = Chkuin (Qquin) ' detects whether the QQ number extracted above is open on this machine
If not myqqin Then ' if it's not running, rerun the QQ program and log in
RunApp (AppPath) '
Wscript.Sleep 10000 ' Wait 10 seconds
Else
Wscript.Sleep 5000 ' Wait 5 seconds
End If
Loop ' Back to continue detection
End If

Function RunApp (AppPath)
Dim obj
Set obj = CreateObject ("Wscript.Shell")
Obj.exec (AppPath)
End Function

Function Chkuin (Qquin)
Set objWMIService = GetObject _
("Winmgmts:\\" & "." & "\root\cimv2")
Set PS = objWMIService.ExecQuery _
("SELECT * from Win32_Process")
For every PS in PS ' lists 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, 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.