I have a simple Python script ("hi.py") as below
import time
print("HI")
time.sleep(5)
I am using Excel VBA to call ""hi.py" by Windows Script Host's Run Method
(code as below). It works.
sub testRun()
Dim wsh As Object
Dim a As Variant
Set wsh = CreateObject("WScript.Shell")
a = wsh.run("C:\tmpFolder\pyProject\myProject\hi.py", 1, True)
End Sub
But if I use Windows Script Host's Exec Method
rather than Run Method
, my computer say hi.py is not a valid win 32 application
.
Sub testExec()
Dim wsh As Object, oexec As Object
Set wsh = CreateObject("WScript.Shell")
Set oexec = wsh.exec("C:\tmpFolder\pyProject\myProject\hi.py")
End Sub
How can I run my python script with Windows Script Host Exec Method
?
Thank you very much.