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


Groups > comp.lang.python > #103072

Re: extending PATH on Windows?

From eryk sun <eryksun@gmail.com>
Newsgroups comp.lang.python
Subject Re: extending PATH on Windows?
Date 2016-02-17 15:17 -0600
Message-ID <mailman.222.1455743909.22075.python-list@python.org> (permalink)
References (2 earlier) <n9v58k$dcl$1@news2.informatik.uni-stuttgart.de> <mailman.168.1455630261.22075.python-list@python.org> <na2bqn$7d7$1@news2.informatik.uni-stuttgart.de> <mailman.217.1455735785.22075.python-list@python.org> <na2l7h$a97$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


On Wed, Feb 17, 2016 at 2:29 PM, Ulli Horlacher
<framstag@rus.uni-stuttgart.de> wrote:
> eryk sun <eryksun@gmail.com> wrote:
>> >
>> > set PATH=%PATH%;%USERPROFILE%\Desktop
>>
>> The AutoRun command (it's a command line, not a script path)
>
> A script path is a legal command line, too.

If the registry value were just a script path, you'd have to modify
your script to chain to the previous script, if any. Since it's a
command line you can simply use the & operator to append another
command.

>> gets run for every instance of cmd.exe
>
> Yes, this is the intended trick!

Do you really intend for your batch file to be run every time cmd.exe
is executed, including every time that every program on the machine
calls the CRT system() function?

Why don't you just install a shortcut to a batch file that starts a
command prompt with the extended PATH?

>> Also, you can't just overwrite a user's AutoRun command like that. If
>> a command currently exists, you have to concatenate your command with
>> the existing command using parentheses and the "&" operator, e.g.
>> (previous_command) & (your_command).
>
> Good hint, thanks!
>
>> Use winreg for this.
>
> system("reg ...") works for me and is easier :-)

system('reg...') won't be able to do that unless you export the key to
a .reg file and parse the existing AutoRun value. It would be simpler
to use subprocess.check_output('reg query ...'), but simpler still and
more reliable to just call QueryValueEx.

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


Thread

extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-16 08:30 +0000
  Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 13:19 +0100
    Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-16 12:38 +0000
      Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 14:38 +0100
      Re: extending PATH on Windows? Thorsten Kampe <thorsten@thorstenkampe.de> - 2016-02-16 14:43 +0100
        Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 17:49 +0000
          Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-17 13:02 -0600
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 20:29 +0000
              Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-17 15:17 -0600
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-17 22:37 +0000
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:55 +0000
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:07 -0600
          Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-17 19:53 -0500
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:24 +0000
              Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-18 21:57 -0500
                Re: extending PATH on Windows? pyotr filipivich <phamp@mindspring.com> - 2016-02-18 19:39 -0800
                Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-19 10:42 +0000
                Re: extending PATH on Windows? Chris Angelico <rosuav@gmail.com> - 2016-02-19 21:48 +1100
                Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-19 07:45 -0500
                Re: extending PATH on Windows? Gisle Vanem <gvanem@yahoo.no> - 2016-02-19 15:18 +0100
                Re: extending PATH on Windows? pyotr filipivich <phamp@mindspring.com> - 2016-02-19 09:04 -0800
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:04 -0600
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-19 12:42 -0600
                Re: extending PATH on Windows? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-19 19:57 -0500
                Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-20 07:31 -0600
          Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-18 06:54 -0600
            Re: extending PATH on Windows? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-02-18 16:50 +0000
  Re: extending PATH on Windows? eryk sun <eryksun@gmail.com> - 2016-02-16 07:17 -0600

csiph-web