How to use VBS to fetch the QQ or TM automatic login code and prevent shutdown
This article mainly introduces how to use VBS to get QQ or TM automatic login code and prevent shutdown, the article is very detailed, has a certain reference value, interested friends must read it!
'Dim QQUIN
Set objWMIService = GetObject _
("winmgmts:\\" & "." & "\ root\ cimv2")
Set ps = objWMIService.ExecQuery _
("SELECT * FROM Win32_process")
For Each ps in ps' lists all running programs in the system
'for each ps in getobject ("winmgmts:\.\ root\\ cimv2:win32_process") .instances_ 'lists all running programs on the system
If LCase (ps.Name) = "qq.exe" Or LCase (ps.Name) = "tm.exe" Then 'detect 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) 'take the QQ number.
End If
Next
If Len (QQUIN) = 0 Then
MsgBox "there are no QQ or TM programs running in the system, please restart QQ or TM, log in and use one button to switch QQ or TM programs, and then run this script."
Else
Do 'cycle detection
Myqqin = chkuin (QQUIN) 'detect whether the QQ number extracted above has been opened locally
If Not myqqin Then'if 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 'returns 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 Each 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 (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
The above is all the contents of the article "how to use VBS to get the QQ or TM automatic login code and prevent it from shutting down". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!