-
Notifications
You must be signed in to change notification settings - Fork 622
/
StopRecording.vbs
69 lines (63 loc) · 2.56 KB
/
StopRecording.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'********************************************************************************************/
'* File Name : StopRecording.vbs
'* Created Date : 2024-10-15 01:50:30
'* Author : Hmily
'* GitHub : http://github.com/ihmily
'* Description : This script is designed to terminate the process of live recording
'********************************************************************************************/
Dim objWMIService, colProcesses, objProcess
Dim intResponse
strComputer = "."
On Error Resume Next
intResponse = MsgBox("确定要结束所有后台直播录制进程吗?", vbYesNo + vbQuestion, "确认结束进程")
If intResponse = vbYes Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
Err.Clear
End If
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'ffmpeg.exe'")
Set colProcesses2 = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'pythonw.exe'")
Set colProcesses3 = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'DouyinLiveRecorder.exe'")
If Err.Number <> 0 Then
Err.Clear
End If
If Not objWMIService Is Nothing And Not colProcesses Is Nothing And Not colProcesses2 Is Nothing Then
If colProcesses2.Count = 0 And colProcesses3.Count = 0 Then
MsgBox "没有找到录制程序的进程", vbExclamation, "提示信息"
WScript.Quit(1)
Else
For Each objProcess in colProcesses
objProcess.Terminate()
If Err.Number <> 0 Then
objShell.Run "taskkill /f /im " & objProcess.Name, 0, True
Err.Clear
End If
Next
End If
Else
objShell.Run "taskkill /f /im " & objProcess.Name, 0, True
End If
MsgBox "已成功结束正在录制直播的进程!" & vbCrLf & "关闭此窗口30秒后自动停止录制程序", vbInformation, "提示信息"
WScript.Sleep 10000
If colProcesses3.Count <> 0 Then
Set colProcesses_ = colProcesses3
Else
Set colProcesses_ = colProcesses2
End If
For Each objProcess in colProcesses_
objProcess.Terminate()
If Err.Number <> 0 Then
objShell.Run "taskkill /f /im " & objProcess.Name, 0, True
Err.Clear
End If
Next
Else
MsgBox "已取消结束录制操作", vbExclamation, "提示信息"
End If
On Error GoTo 0
Set objWMIService = Nothing
Set colProcesses = Nothing
Set colProcesses2 = Nothing
Set colProcesses3 = Nothing
Set objProcess = Nothing
Set objShell = Nothing