473,320 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Environment Variables in .NET

How to set the environment variable?

I guess System.Environment gives readonly access to it.

Regards,
NetPointer.
Jul 21 '05 #1
2 5915
Hi,

You can't change the environment variables of the current process, but what
you can do is to pass a new set of environment variables to a new Process
object through its StartInfo property. Another object is to use the
System.Management namespace, and finally, you could change the registry
directly.

Regards

Dennis

-------------------

Dennis Doomen
Sioux T.S.O
de***********@sioux.nl

"NetPointer" <sh**************@intel.com> wrote in message
news:bj*********@news01.intel.com...
How to set the environment variable?

I guess System.Environment gives readonly access to it.

Regards,
NetPointer.

Jul 21 '05 #2
Last minute addition:

[DllImport("kernel32.dll", CharSet=CharSet.Unicode)]
public static extern void SetEnvironmentVariable(string name, string value);

Will do the trick as well.

Dennis Doomen wrote:
Hi,

You can't change the environment variables of the current process, but what
you can do is to pass a new set of environment variables to a new Process
object through its StartInfo property. Another object is to use the
System.Management namespace, and finally, you could change the registry
directly.

Regards

Dennis

-------------------

Dennis Doomen
Sioux T.S.O
de***********@sioux.nl

"NetPointer" <sh**************@intel.com> wrote in message
news:bj*********@news01.intel.com...
How to set the environment variable?

I guess System.Environment gives readonly access to it.

Regards,
NetPointer.


--
Dennis Doomen
Sioux T.S.O. Netherlands

de***********@sioux.nl

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Lindstrom | last post by:
Hello- I am running python 2.3. on an HP-9000 box running Unix and have a POSIX script that sets up my production environment. I would like to run the script from inside a python routine and...
28
by: Christian | last post by:
Another question from a not even newbie: In Unix you can set an environment variable with the command export PYTHONPATH but I would like to set the variable from at .py script. So my question...
4
by: Bill Davidson | last post by:
All: I've found the 'Environment.GetEnvironmentVariable()' method; but how do I create and/or set an environment variable? Thanks, Bill
4
by: Ron Clarke | last post by:
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...
6
by: Fuzzyman | last post by:
Hello all, I would like to set a Windows Environment variable for another (non-child) process. This means that the following *doesn't* work : :: os.environ = value In the ``win32api``...
1
by: pagates | last post by:
Hi All, What's the "best" way to get System Environment Variables (VS2003)? Environment.GetEnvironmentVariable("xxx") only gets user Environment variables. Thanks, pagates
2
by: ANarula | last post by:
I am running into a strange problem. I have perl script which reads the "APPDATA" environment variable, and does some work on that directory. When I a launch this script from Command Prompt, it...
3
by: Tristan | last post by:
Hello community: I post this because I could not find satisfactory answers in the posts generated by this nice group. I work on winXP. I have many little python applications in different folders,...
3
by: smitty1e | last post by:
Just a fun exercise to unify some of the major input methods for a script into a single dictionary. Here is the output, given a gr.conf file in the same directory with the contents stated below: ...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.