Re: How do you create and set environment variables?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ron Clarke (ron.clarke_at_hp.com)
Date: 02/06/04


Date: Fri, 6 Feb 2004 13:35:50 -0800

Aah, that makes more sense. For some reason it did not occur to me that the
contents of the EnvironmentVariables property might be able to be modified.
That's what I need. Thanks.

-Ron

"Stoitcho Goutsev (100) [C# MVP]" <100@100.com> wrote in message
news:%23ka5GwO7DHA.3024@tk2msftngp13.phx.gbl...
> Hi Ron,
> You cannot change the invironment on already running process.
> The set of envirnoment variables can be only changed upon process
creation.
>
> About the EnvironmentVariables property. The property itself is readonly
> because it returns StringDictionary (collection) and you cannot set a new
> collection. But you can modify (add, delete, change) its content.
> Once you compose the set of environment variables you start the new
process
> using that ProcessStartInfo.
> When the process is up and running no one can change its environment
except
> the process itself.
>
> --
> B\rgds
> 100
>
> "Ron Clarke" <ron.clarke@hp.com> wrote in message
> news:u38U3SO7DHA.1672@TK2MSFTNGP12.phx.gbl...
> > Thanks, but I've already looked there. Unless the documentation is
wrong,
> > you can only get the values, you cannot set them.
> > For example, the ProcessStartInfo.EnvironmentVariables property is
defined
> > this way:
> > public StringDictionary EnvironmentVariables {get;}
> >
> > I could get some variables and modify the dictionary contents, but then
> how
> > do I get them back into the environment if the property does allow a
> "set"?
> > For something that should be so simple, there must be a way to do it!
> >
> > Thanks in advance,
> > Ron
> >
> >
> >
> > "Stoitcho Goutsev (100) [C# MVP]" <100@100.com> wrote in message
> > news:uGqxi6N7DHA.2560@TK2MSFTNGP09.phx.gbl...
> > > Hi Ron,
> > > Take a look at Process and ProcessStartInfo classes. Using
> > ProcessStartInfo
> > > you can set envionment variables.
> > > Each process has its own set of envirnment variables so, you don't
have
> to
> > > remove yours when the process terminates
> > >
> > > --
> > > HTH
> > > B\rgds
> > > 100
> > >
> > > "Ron Clarke" <ron.clarke@hp.com> wrote in message
> > > news:OKObiaN7DHA.2044@TK2MSFTNGP10.phx.gbl...
> > > > I have an application that starts other processes. The app needs to
> > > > create/set a few environment variables when a process starts, let
the
> > > > process run, then remove the environment variables when the process
> > > > terminates. Looking through the C# and .NET docs, I've found how to
> get
> > > > environment variables, but not how to create and set them. I found
the
> > > > EnvironmentPermissions class which grants access, but that's not
> enough.
> > > > Can anyone help me here; the functionality must be out there
> somewhere!
> > > > Thanks.
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: eclipse
    ... Yes I am using eclipse right now with LynuxWorks. ... You will need to modify your environment parameters. ... 'gcc' versions. ...
    (comp.os.lynx)
  • Re: (OT) Global warming - it doesnt matter whats the cause!
    ... So let's assume that the warming observed recently is not caused by humans ... The fact is, even beavers modify their environment, but I suspect you ... Technology modifies the environment. ...
    (talk.origins)
  • Re: Interface manue buttons vanished in Office 2008 for mac
    ... I have both Simplified Chinese and Traditional Chinese enabled in ... environment or Chinese Traditional environment, ... May be to modify some system files can solve the problems, ... McGhie Information Engineering Pty Ltd ...
    (microsoft.public.mac.office)
  • Re: Code to modify process environment?
    ... >> I remember some discussion earlier this year about code to modify ... >> process environment (as opposed to CRTL environment, ... > if you shift things around, the pointers may no longer point to whatever ...
    (comp.os.os2.programmer.misc)
  • Re: What is the Result from Invoking this Halt Function?
    ... | "Will Twentyman" wrote in message ... you can modify the environment to "lie". ...
    (sci.logic)