[英]How to make a Python script run a powershell script after it executes
我有两个脚本,一个基于Python,另一个基于Powershell。 我的要求是,我需要在启动时先运行Python脚本,然后再运行powershell脚本。
使用Task Scheduler,我可以运行Python脚本,但是我需要找到一种在python脚本完成后运行powershell脚本的方法。
在线研究表明,我可以添加以下内容:
os.system(“ powershell.exe script.ps1”)在我的Python脚本中,但是抛出错误:(unicode error)'unicodeescape'编解码器无法解码位置中的字节.....
有什么建议么?
而不是从Python脚本内部调用Powershell脚本,您应该使用任务计划程序本身运行这两个脚本。
假设你给调度命令是像python script.py
,你应该改变它cmd_script.cmd
其中的内容cmd_script.cmd
将python script.py & powershell.exe script.ps1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.