0

We have a problem on one PC, which seems not to be honouring arguments in .bat scripts, i.e. not passing them on to invoked python scripts. It works fine on 10 or so other very similar machines.

We have a bat script like this:

@REM Just pass all arguments directly to the python script of the same name
@%~dpn0.py %*

On this one PC, it seems that the arguments don't get passed on to the python script being invokved.

This idiom is used all over the place in our build spaces - and we can't work out why it fails on just one machine.

Are there any suggestions as to the cause, or how we might debug the issue, please?

  • OS: Windows 7 Pro, 64-bit
  • Python version: 2.7.6
1
  • 3
    For debugging purposes, what happens if you echo %* instead of calling your Python script and passing the parameters? Are you able to see all the arguments? Have you reached the 8191 command line limit as explained here? support.microsoft.com/kb/830473
    – JSanchez
    Jan 24, 2014 at 17:54

1 Answer 1

2

Clare asked this question on my behalf, but I've since worked out what is going on. Thanks to JSanchez for the start pointer to the answer. It wasn't the bat script that was the problem, rather the python it was calling; I had found a work around where typing

python the_python_script.py the arguments 

worked already. What had not occurred to me was to check just typing

the_python_script.py the arguments

at the command line and letting Windows take care of what python to use to run the script

When I did it that way, the program manifested the same issue - no args.

This in turn then led me to

So I checked the registry - my association was indeed broken

Fixed, and now this seems to work ... so it wasn't the .bat script, rather the python file association.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .