需求: 一個python.exe 可能放在任意的路徑下, 希望寫一個vbs 腳本執行這個python.exe 且不要顯示cmd 窗口
實做:
currentpath = createobject("Scripting.FileSystemObject").GetFolder(".").Path // 獲取當前腳本所在的路徑
WScript.Echo currentpath // 僅僅是debug 作用,實際腳本應該去掉
pythonpath = currentpath + "\Python27\python.exe " // 腳本所在目錄和可執行程序所在的目錄相對關係固定
runservercmd = currentpath + "\railway\manage.py runserver"
cmd1 = "cmd /c " + pythonpath + runservercmd
WScript.Echo pythonpath // 僅僅是debug 作用,實際腳本應該去掉
WScript.Echo runservercmd // 僅僅是debug 作用,實際腳本應該去掉
WScript.Echo cmd1 // 僅僅是debug 作用,實際腳本應該去掉
set ws=WScript.CreateObject("WScript.Shell")
ws.Run cmd1,vbhide