Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96880

Re: .bat file trouble.

References <d4e0dfd5-a87e-49a4-9a7c-696aabf527f2@googlegroups.com> <mth4e7$atq$1@dont-email.me>
From eryksun <eryksun@gmail.com>
Date 2015-09-20 09:53 -0500
Subject Re: .bat file trouble.
Newsgroups comp.lang.python
Message-ID <mailman.40.1442760834.21674.python-list@python.org> (permalink)

Show all headers | View raw


On 9/18/15, Christian Gollwitzer <auriocus@gmx.de> wrote:
> Am 18.09.15 um 11:06 schrieb bobertini@googlemail.com:
>
>> We originally thought that it was because it was missing the files:
>> process_init.py and process_global_variables.py however they are
>> right there in the same directory.
>
> Concerning that, windows usually runs a .bat file in the directory where
> it is situated, so putting the python fies there /should/ work, but you
> can also set this using the right-click menu (execute in...), if you
> make a link to the desktop.

It's fragile to depend on being started by Explorer or a shell link.
For example, if the batch is run from an existing cmd shell, then it
runs with cmd's current working directory. Or another process could
run the batch file with a different working directory. If you actually
want the batch to find the scripts relative to its own directory, then
it should use the %0 environment variable, which references the
fully-qualified path of the batch file. Getting just the directory,
i.e. its [d]rive and [p]ath, is expressed as %~dp0. Note that this
path includes a trailing backslash.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

.bat file trouble. bobertini@googlemail.com - 2015-09-18 02:06 -0700
  Re: .bat file trouble. Steven D'Aprano <steve@pearwood.info> - 2015-09-18 19:32 +1000
  Re: .bat file trouble. Christian Gollwitzer <auriocus@gmx.de> - 2015-09-18 15:45 +0200
    Re: .bat file trouble. eryksun <eryksun@gmail.com> - 2015-09-20 09:53 -0500
    Re: .bat file trouble. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-20 09:43 -0600

csiph-web