Python Forum
batch file for running python scipt in Windows shell
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
batch file for running python scipt in Windows shell
#1
Hi,

I am doing an assignement in a Python learning book in which i have to run my Python script in the Windos shell. It says that i have to make a batch file containing:

Quote:@py.exe C:\yourpath\PythonScript.py %*
@pause

What is the function of this bat file?
Reply
#2
The @ in a batch file is suppressing the echoing of the command.
Often in batch files the following pattern is used, to switch the echoing of commands globally off:
@echo off
py.exe is the program, which finds the latest Python Interpreter on well-known paths.
C:\yourpath\PythonScript.py is the program itself.
The %* is for arguments.
google Wrote:%* expands to the complete list of arguments passed to the script. You typically use it when you want to call some other program or script and pass the same arguments that were passed to your script. The %* modifier is a unique modifier that represents all arguments passed in a batch file.

The command pause will be executed after the python program has been finished. The command pause waits for a key press.
This is often used to see debug output from a broken program. If it was not run direct in a terminal, the new terminal will instantly close, and you've no time to read the Exceptions.
tester_V likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
Thank you for the info. But what is the purpose of this batch file, as i can already run the .py program from the system shell?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  set -x shell equivalent of python, possible/available? ggpf900 1 456 Jan-25-2025, 08:01 PM
Last Post: Gribouillis
  Can a windows file be 'remapped' in Linux ? jehoshua 3 904 Dec-07-2024, 03:33 AM
Last Post: jehoshua
  How to re-register .py file extension to new moved Python dir (on Windows)? pstein 5 1,346 Nov-06-2024, 03:06 PM
Last Post: DeaD_EyE
  Executable file compiled by PyInstaller does not work on Windows 7 amusaber 1 1,823 Jul-11-2024, 02:59 PM
Last Post: DeaD_EyE
  error "cannot identify image file" part way through running hatflyer 0 1,995 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Help creating shell scrip for python file marciokoko 10 3,400 Sep-16-2023, 09:46 PM
Last Post: snippsat
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 8,125 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python script running under windows over nssm.exe JaroslavZ 0 1,731 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  Launch Python IDLE Shell from terminal Pavel_47 5 2,636 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Web project and running a .py file emont 0 1,236 Dec-11-2022, 11:15 PM
Last Post: emont

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020