简体   繁体   中英

Python and windows scheduler - run py script that invokes other scripts

I am trying to set up a windows scheduled task to run a python script that runs two other scripts. I use os package to do it with the code like below:

#mainScript.py
    import os
    
        os.system('script1.py 1')
        os.system('scripts.py 1')

The script works in a scheduled task except when I add the above code. What I mean If use script1.py in my bat file it works, but if I use the mainScript.py it gives me the error code.

'script1.py' is not recognized as an internal or external command,
operable program or batch file.
'script2.py' is not recognized as an internal or external command,
operable program or batch file.

I know I can just move all the code into mainScript but wonder if there is anything I can do to have.

You need to specify wich program will run the script. Try this :

os.system('python script1.py')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM