Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: SYSTEM and USER environment (was Your confirmation is requiredto join the Python-list mailing list)

Reply
Thread Tools

Re: SYSTEM and USER environment (was Your confirmation is requiredto join the Python-list mailing list)

 
 
Dave Angel
Guest
Posts: n/a
 
      05-04-2009
Allan Yuan wrote:
> Hi,
> I just wanna know how to set SYSTEM variables and USER variables of windows,
> but got no way.
>
> Firstly I thought "os.environ + os.system" may work well, but found no way
> to let "os.environ" run to retrive USER variables.
>
> Then I tried win32api, finding the GetEnvironmentVariables() mixing SYSTEM
> and USER variables up, and SetEnvironmentVariables() failing to add
> variables.
>
> Could you help me, please?
> Thanks a lot.
>
>

First, you need to put a meaningful subject line on a query to the
list. Hopefully you also did the confirmation, so that you'll actually
be getting the list emails.

Next, your problem. SYSTEM and USER variables are a uniquely Windows
concept, and as far as I know, have no direct counterpart in Python.
These are really just names used in the Control Panel applet to refer to
two sections of the registry which are used to define which environment
variables a task will start with, if the task is started directly from
Explorer. Tasks that are started by other tasks (eg. the command line)
get environment variables as defined by the parent.

So, there are at least three obvious ways a process gets started. One
is by explorer, in which case it gets the environment described above.
Two is by a DOS box, in which case it gets the environment variables
according to the rules of the CMD shell. And third is from an arbitrary
3rd party process, in which case it's up to that developer.

So, which are you trying to change? I'm suspecting you're interested in
the Explorer version, for example that launches a program from a
shortcut on the desktop, or via an association with a particular file
extension. i don't know which registry variables are involved, but
there are two registry keys,
Try: hklm/SYSTEm/CurrentControlSet/Control/Session
Manager/Environment for the SYSTEM environment variables
and hkcu/Environment for the USER environment variables

Experiment first with REGEDIT, then when you get the behavior you want,
look up module _winreg (or winreg in Python 3.0) to do it
programmatically. Notice that existing DOS boxes won't see these new
variables, only things launched by Explorer or the equivalent.

It's also possible you just want to set environment variables for a
particular DOS box session. In that case, use a .BAT or .CMD file, in
which a SET statement tells the shell what values to use next time it
launches.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby APIs for facebook questions & answers Mailing List/Forum NowLive - Join Us Gerald Bauer Ruby 1 12-19-2007 12:19 AM
Your confirmation is required to join the TECHWR-L mailing list techwr-l-confirm+22d099e2f3d881b010eaeb38c05837f62bbf60ad@lists.techwr-l.com Python 0 09-17-2007 11:24 PM
The Hidden Wiki is Gone ... so do I have to join a mailing list? riprock Computer Security 3 06-16-2007 01:03 AM
You must join New York Paid To Read !!!!!!! NewYork PTR is online!!! JOIN NOW!!!!!! Alan Silver ASP .Net 0 06-05-2006 03:27 PM
[wopronet] Your confirmation is needed to join the Group wopronet-subscribe-conf-1080784105.hgkjbmmdhhngpkhjgmkj@smartgroups.com Python 0 04-01-2004 01:48 AM



Advertisments