473,237 Members | 1,390 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,237 software developers and data experts.

how can i add environment variable to my VS.NET 2003 project ?

Hi,

my application use environment variable, let call it FOO.

how can i add the FOO environment variable to my project or my solution,

so the line

string foo = Environment.GetEnvironmentVariable("FOO");

will work ?

Thanks.
Feb 21 '06 #1
6 5304
The process that launches your application must set the environment variable
before it launches your application. For example, you can write a simple
batch file that sets the environment variable and then launches your
executable. It can be as simple as...

set FOO=SomeValue
MyApp.exe

"yaron" <ya***@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hi,

my application use environment variable, let call it FOO.

how can i add the FOO environment variable to my project or my solution,

so the line

string foo = Environment.GetEnvironmentVariable("FOO");

will work ?

Thanks.

Feb 21 '06 #2
i forgot to tell a few details :
the problem i need to solve is to run 2 instances of my sample app
simultaneously from the folder with 2 different app configurations. so FOO is
the name of myconfig.xml file.

1. i need to be able to run my project from Visual Studio.NET 2003, so i
don't know how to this set FOO=SomeValue inside the Visual Studio IDE and not
from outside batch file. so every time the user want to change FOO value he
will change it and then press F5 (Run) from the VS.NET without the need to
leave or restart the IDE.

2. the user need to run 2 instances simultaneously of my sample application
with different values for FOO from the same sample app folder.

3. without using Main args[] parameters array ?

shortly something like VM paramerers in java.

Thanks.
"David Levine" wrote:
The process that launches your application must set the environment variable
before it launches your application. For example, you can write a simple
batch file that sets the environment variable and then launches your
executable. It can be as simple as...

set FOO=SomeValue
MyApp.exe

"yaron" <ya***@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hi,

my application use environment variable, let call it FOO.

how can i add the FOO environment variable to my project or my solution,

so the line

string foo = Environment.GetEnvironmentVariable("FOO");

will work ?

Thanks.


Feb 21 '06 #3
Hello yaron,

Use Environment.SetEnvironmentVariable for .NET 2.0 or P/Invoke
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool SetEnvironmentVariable(string lpName, string lpValue);

y> Hi,
y> my application use environment variable, let call it FOO.
y> how can i add the FOO environment variable to my project or my
y> solution,
y> so the line
y> string foo = Environment.GetEnvironmentVariable("FOO");
y> will work ?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 21 '06 #4
can i set environment variable in the Visual Studio.NET 2003 IDE or in the
Visual Studio project properties ? or start debuging from a batch file ?

Thanks.
"Michael Nemtsev" wrote:
Hello yaron,

Use Environment.SetEnvironmentVariable for .NET 2.0 or P/Invoke
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool SetEnvironmentVariable(string lpName, string lpValue);

y> Hi,
y> my application use environment variable, let call it FOO.
y> how can i add the FOO environment variable to my project or my
y> solution,
y> so the line
y> string foo = Environment.GetEnvironmentVariable("FOO");
y> will work ?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Feb 21 '06 #5
Hello yaron,

Nope. U can't change machine settings from the VS IDE, but u can call some
app in Pre/Post build action, where your machine settings will be set.
y> can i set environment variable in the Visual Studio.NET 2003 IDE or
y> in the Visual Studio project properties ? or start debuging from a
y> batch file ?
y>
y> Thanks.
y>
y> "Michael Nemtsev" wrote:
y>
Hello yaron,

Use Environment.SetEnvironmentVariable for .NET 2.0 or P/Invoke
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool SetEnvironmentVariable(string lpName, string
lpValue);
y> Hi,
y> my application use environment variable, let call it FOO.
y> how can i add the FOO environment variable to my project or my
y> solution,
y> so the line
y> string foo = Environment.GetEnvironmentVariable("FOO");
y> will work ?
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 21 '06 #6
Hi Michael,

if before loading VS IDE my environment variable FOO==aaa, then in the pre
or post build event i will write the command SET FOO=bbb then i will run the
program from the VS IDE (Ctrl^F5) would i see the new value for FOO which is
bbb ?
or maybe there is other trick to cause the running program from the IDE to
see the new value for FOO ?

Thanks a lot.
"Michael Nemtsev" wrote:
Hello yaron,

Nope. U can't change machine settings from the VS IDE, but u can call some
app in Pre/Post build action, where your machine settings will be set.
y> can i set environment variable in the Visual Studio.NET 2003 IDE or
y> in the Visual Studio project properties ? or start debuging from a
y> batch file ?
y>
y> Thanks.
y>
y> "Michael Nemtsev" wrote:
y>
Hello yaron,

Use Environment.SetEnvironmentVariable for .NET 2.0 or P/Invoke
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool SetEnvironmentVariable(string lpName, string
lpValue);
y> Hi,
y> my application use environment variable, let call it FOO.
y> how can i add the FOO environment variable to my project or my
y> solution,
y> so the line
y> string foo = Environment.GetEnvironmentVariable("FOO");
y> will work ?
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Feb 22 '06 #7

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

Similar topics

1
by: Shahzad Atta | last post by:
Hi there, I am using a batch file to do some zipping task. This batch file get executed on postbuild event which I set through project properties. Now when I execute the batch file from command...
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...
13
by: Jimmy Cracker | last post by:
Is it completely impossible in UNIX to push an environment variable to the parent shell? I would like to do something like this: main(int argc, char *argv) { char *var; var = (char...
1
by: Bonj | last post by:
Hi My application installs a front-end GUI, which runs code when buttons are clicked. It also installs a command-line utility, that is a console application. They are both installed to the...
4
by: | last post by:
Hi all, I am trying to append a certain string to the PATH environment variable programmatically. I am able to read what is in the variable using the System.Environment method...
3
by: Strauss | last post by:
Hi: I'm setting the INCLUDE environment variable, but VC is not searching it for header files (I've checked it with filemon). I've tried with user variable, machine variable, rebooted the...
0
by: Joe HM | last post by:
Hello - I am putting together a little ConsoleApplication that is supposed to check for an Environment Variable and create it if it does not exist. I found some code that will add a new...
2
by: Andy | last post by:
Hi guys I having a problem creating a report in Access 2003 project talking to a SQL database through and ODBC connect. After hours of trying things from Access Help, MSDN and Google I still...
0
by: =?Utf-8?B?QWlqdW4=?= | last post by:
Hi! I have just upgraded my vs 2003 project to vs 2005 project for my web application project. However, there are fews things that I need your help to ensure that I have done things correctly...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.