要详细说明安斯加的补救措施:
从命令行“ works”启动.vbs,因为外壳程序将扩展名.vbs与应用程序关联(例如cscript / wscript;请参阅ftype,assoc,cscript // E,cescript // S)。
subprocess.call()
不会打开外壳程序,因此可以指定应用程序(c|wscript.exe
)或自己启动外壳程序:
import subprocess
#subprocess.call("notepad") # works
#subprocess.call("dir") # [Error 2] The system cannot find the file specified
# no shell, no intrinsics
#subprocess.call("19112944.vbs") # [Error 193] %1 is not a valid Win32 application
# no shell, can't associate .vbs with c|wscript.exe
subprocess.call("cscript 19112944.vbs") # works
subprocess.call("cmd /c 19112944.vbs") # works
# have shell, can associate .vbs with c|wscript.exe