Click here to Skip to main content
15,922,574 members
Home / Discussions / C#
   

C#

 
GeneralRe: vbscript to c# Pin
Pete O'Hanlon11-Jun-13 3:19
mvePete O'Hanlon11-Jun-13 3:19 
GeneralRe: vbscript to c# Pin
fernando_moca11-Jun-13 3:26
fernando_moca11-Jun-13 3:26 
QuestionNeed help regarding developing windows service Pin
Tridip Bhattacharjee10-Jun-13 9:18
professionalTridip Bhattacharjee10-Jun-13 9:18 
AnswerRe: Need help regarding developing windows service Pin
Richard Deeming10-Jun-13 9:27
mveRichard Deeming10-Jun-13 9:27 
GeneralRe: Need help regarding developing windows service Pin
Ron Nicholson10-Jun-13 9:52
professionalRon Nicholson10-Jun-13 9:52 
AnswerRe: Need help regarding developing windows service Pin
Rob Philpott10-Jun-13 10:09
Rob Philpott10-Jun-13 10:09 
AnswerRe: Need help regarding developing windows service Pin
Abhinav S10-Jun-13 20:15
Abhinav S10-Jun-13 20:15 
QuestionHow to draw 3D electron model around Atom using XNA?? Pin
nada 101510-Jun-13 0:59
nada 101510-Jun-13 0:59 
AnswerRe: How to draw 3D electron model around Atom using XNA?? Pin
Richard MacCutchan10-Jun-13 1:48
mveRichard MacCutchan10-Jun-13 1:48 
GeneralRe: How to draw 3D electron model around Atom using XNA?? Pin
nada 101510-Jun-13 1:54
nada 101510-Jun-13 1:54 
GeneralRe: How to draw 3D electron model around Atom using XNA?? Pin
Richard MacCutchan10-Jun-13 2:02
mveRichard MacCutchan10-Jun-13 2:02 
GeneralhI How Can i Expand Window? Pin
SgtSS9-Jun-13 23:41
SgtSS9-Jun-13 23:41 
AnswerRe: hI How Can i Expand Window? Pin
Abhinav S10-Jun-13 0:06
Abhinav S10-Jun-13 0:06 
GeneralRe: hI How Can i Expand Window? Pin
SgtSS10-Jun-13 14:31
SgtSS10-Jun-13 14:31 
QuestionRun RegisterStartupScript multiple times in c# Pin
Jun Xian9-Jun-13 22:05
Jun Xian9-Jun-13 22:05 
Questionstuck in (dll registration in system32 by c#) Pin
Sneha Bisht9-Jun-13 21:01
Sneha Bisht9-Jun-13 21:01 
AnswerRe: stuck in (dll registration in system32 by c#) Pin
Abhinav S9-Jun-13 21:47
Abhinav S9-Jun-13 21:47 
AnswerRe: stuck in (dll registration in system32 by c#) Pin
Dave Kreskowiak10-Jun-13 1:34
mveDave Kreskowiak10-Jun-13 1:34 
Questionc# Pin
zofi519-Jun-13 20:16
zofi519-Jun-13 20:16 
AnswerRe: c# Pin
Abhinav S9-Jun-13 21:49
Abhinav S9-Jun-13 21:49 
AnswerRe: c# Pin
bfis10813710-Jun-13 0:38
bfis10813710-Jun-13 0:38 
AnswerRe: c# Pin
OriginalGriff10-Jun-13 9:09
mveOriginalGriff10-Jun-13 9:09 
QuestionHow to deal with environment variables and non admin users Pin
bfis1081379-Jun-13 2:08
bfis1081379-Jun-13 2:08 
AnswerRe: How to deal with environment variables and non admin users Pin
Eddy Vluggen9-Jun-13 5:06
professionalEddy Vluggen9-Jun-13 5:06 
GeneralRe: How to deal with environment variables and non admin users Pin
bfis1081379-Jun-13 10:30
bfis1081379-Jun-13 10:30 
The path I tried was in 2 places. First I made a folder in the c root. Then I thought it had to do with permissions so I used the public folder. This is c:\users\public on win7/vista and it's c:\documents and settings\All Users in xp. Like I said I used Application.StartupPath and it works but only when I start it myself. When it runs automatically at startup, "Application.StartupPath" points to c:\users\current user. With all that being said I found a solution. I add an environment variable which does require elevation but it's a one time thing when the app is first installed which i use a separate app to do(which i call from the main app) so as to not require the higher privilege all the time. That much I had working before. Where I got stuck was trying to retrieve the variable. It would require elevation as well which was unacceptable. However I found a solution.

I found this on another site but since I know how some sites are with links I am not going to post the link. Here is the code I used to retrieve an environment variable without elevation.

C#
string keyName = @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment\";
string path = (string)Registry.LocalMachine.OpenSubKey(keyName).GetValue("variablename", "", RegistryValueOptions.DoNotExpandEnvironmentNames);

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.