Running python from a usb drive

Jason tenax.raccoon at gmail.com
Wed Sep 13 12:00:34 EDT 2006


cjl wrote:
> Thorsten:
>
> Thank you for your reply.
>
> > Setting environment variables has only effect on the process itself
> > and the subprocesses. This has nothing to do with Windows, it's the
> > same with Linux.
>
> True, and the changes to path and pythonpath are gone after I close the
> console window, but the results of the assoc and ftype commands are
> changes to the registry that linger. If I run my setup on a computer
> that has python installed, I will overwrite the pre-existing registry
> settings. I can restore them with a script, but I can't guarantee that
> my restore script will run.
>
> I'm still looking for a way to modify these temporarily, but it looks
> like I might be "up the creek" on this one. Oh well.
>
> Thanks again,
> CJL

I notice that you've already got the environmental variables set up to
run your Temp-Python.  You can retrieve the current associations (if
any) by using the assoc and ftype commands:

C:\>assoc .py
.py=Python.File

C:\>ftype Python.File
Python.File="C:\Python24\python.exe" "%1" %*

C:\>assoc .NotAnExtension
File association not found for extension .NotAnExtension

C:\>

Using this information, you could write a little python script with
your distribution which records the current file associations and
settings.  Then, when you're ready to revert, you run another little
python script which restores the associations.

These associations are also stored in the registry.  You could back up
the registry keys which you know will be modified, make the registry
changes yourself, and restore the registry settings at finish.  It
would require Python's win32 extension modules, though.

I don't know how you could do it without using a
backup/run-stuff/restore sequence.

    --Jason




More information about the Python-list mailing list