-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.vbs
49 lines (38 loc) · 1.35 KB
/
run.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
Dim win_shell, main_path, current_dir, python3_path, output_path
current_dir= left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
main_path = current_dir & "Main.py"
main_path = Replace(main_path, "\", "\\")
output_path = current_dir & "output.txt"
set win_shell = WScript.CreateObject("WScript.Shell")
comm = "cmd /c where python3 >" & output_path & ""
return=win_shell.Run(comm, 0, true)
output_path = Replace(output_path,vbCr,"")
output_path = Replace(output_path,vbLf,"")
output_path = CStr(Trim(output_path))
set objFSO = CreateObject("Scripting.FileSystemObject")
If not objFSO.FileExists(output_path) Then
WScript.Echo "output.txt file not found"
WScript.Quit
End If
set file = objFSO.OpenTextFile(output_path, 1)
python3_path = file.ReadAll
file.Close
python3_path = Replace(python3_path,"\","\\")
python3_path = Replace(python3_path,vbCr,"")
python3_path = Replace(python3_path,vbLf,"")
python3_path = CStr(Trim(python3_path))
If not objFSO.FileExists(main_path) Then
WScript.Echo "Main.py file not found"
WScript.Quit
End If
If not objFSO.FileExists(python3_path) Then
WScript.Echo "python3.exe not found"
WScript.Quit
End If
command= python3_path &" "& main_path
win_shell.Run command,0
Set win_shell = Nothing
set main_path = Nothing
set current_dir = Nothing
set python3_path = Nothing
set output_path = Nothing