2016-03-09 286 views
0

我有兩個腳本,一個是基於Python的,另一個是基於powershell的腳本。 我的要求是我需要先運行Python腳本,然後在啓動時運行powershell腳本。如何讓Python腳本在執行後運行powershell腳本

使用任務計劃程序我可以運行Python腳本,但我需要找到一種方法在python腳本完成後運行powershell腳本。

一些研究顯示在線,我可以添加這樣的:在我的Python腳本

使用os.system( 「powershell.exe script.ps1」),但拋出一個錯誤:(Unicode的錯誤)「unicodeescape '編解碼器不能解碼位置上的字節.....

有什麼建議嗎?

回答

3

不應從Python腳本中調用Powershell腳本,而應使用任務調度程序本身運行這兩個腳本。

假設你給調度是像python script.py的命令,你應該將其更改爲cmd_script.cmd其中cmd_script.cmd的內容將是python script.py & powershell.exe script.ps1