How to run python script using batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xhai
Posts: 39
Joined: 13 Jun 2013 09:33

How to run python script using batch

#1 Post by xhai » 16 Aug 2014 12:23

Hi there again..

I have a phython script named script.py everytime i want to use it i need to shift+right click mouse then navigate to open command window here / CMD then type the syntax "script.py -e filename"

Is there a way that a batch script can run a phython script, making it more easier

Thank you,

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: how to run phyton script using batch

#2 Post by ShadowThief » 16 Aug 2014 16:27

If the filename changes frequently:

Code: Select all

@echo off
set /p fname=Enter the full path of the file to use:
script.py -e "%fname%"


If the filename will never change:

Code: Select all

@echo off
script.py -e filename

xhai
Posts: 39
Joined: 13 Jun 2013 09:33

Re: How to run python script using batch

#3 Post by xhai » 17 Aug 2014 13:05

Thanks thief..

The code was so simple, but very useful

Post Reply