Jayesh Acharya
asked on
enviroment variables in c#
My application "SC" is going to exectued standalone on a desktop (the user will enter a username / passwrd to connect to the database) Also it connects via another application that is already logged onto the database.
The question I have is how can i pick up the enviroment variables related to user / password / and database when the application "SC" if executed from another application that is already connected to the oracle database. The other application would be executed from a citrix server if that makes any difference ...
I have tried to use
test = Environment.GetEnvironment Variable(" USER");
MessageBox.Show("test = " + test + " \n"
, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information );
test is always blank wether its from the desktop or from the citrix application
The question I have is how can i pick up the enviroment variables related to user / password / and database when the application "SC" if executed from another application that is already connected to the oracle database. The other application would be executed from a citrix server if that makes any difference ...
I have tried to use
test = Environment.GetEnvironment
MessageBox.Show("test = " + test + " \n"
, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information
test is always blank wether its from the desktop or from the citrix application
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thanks everyone for the help, it has helped me get to the information i need, in the end i used
what I found was that when the calling program called SC, it had looged onto the oracle database 1st, so the envirment variables where set for that instance, but when SC is called directly from windows you have not logged onto the database and those variableswhere not set
test = Environment.GetCommandLine Args();
for (int i = 0; i < test.GetLength(0); i++)
{
if (test[i].StartsWith("USER= "))
{ luser = test[i].Substring(5); }
else if (test[i].StartsWith("PASSW ORD="))
{ lpswd = test[i].Substring(9); }
else if (test[i].StartsWith("DATAB ASE="))
{ ldb = test[i].Substring(9); }
}
what I found was that when the calling program called SC, it had looged onto the oracle database 1st, so the envirment variables where set for that instance, but when SC is called directly from windows you have not logged onto the database and those variableswhere not set
test = Environment.GetCommandLine
for (int i = 0; i < test.GetLength(0); i++)
{
if (test[i].StartsWith("USER=
{ luser = test[i].Substring(5); }
else if (test[i].StartsWith("PASSW
{ lpswd = test[i].Substring(9); }
else if (test[i].StartsWith("DATAB
{ ldb = test[i].Substring(9); }
}
ASKER
gave good pointers and helped me understand what direction to take
ASKER