On Wed, Feb 17, 2016 at 2:29 PM, Ulli Horlacher <frams...@rus.uni-stuttgart.de> wrote: > eryk sun <eryk...@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. -- https://mail.python.org/mailman/listinfo/python-list