Link to home
Create AccountLog in
Avatar of Jayesh Acharya
Jayesh AcharyaFlag for United States of America

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.GetEnvironmentVariable("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
ASKER CERTIFIED SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Jayesh Acharya

ASKER

the username /password is the oracle database, the application that executes "SC" is a windows gui app and the SC app is a WinFrom written in C#
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.GetCommandLineArgs();
            for (int i = 0; i < test.GetLength(0); i++)
             {
                 if (test[i].StartsWith("USER="))
                 { luser = test[i].Substring(5); }
                 else if (test[i].StartsWith("PASSWORD="))
                 {  lpswd = test[i].Substring(9); }
                 else if (test[i].StartsWith("DATABASE="))
                 {  ldb = test[i].Substring(9); }
             }
gave good pointers and helped me understand what direction to take