473,327 Members | 2,103 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,327 software developers and data experts.

System.Diagnostics.Process.StartInfo.EnvironmentVa riables is lying to me

ceh
Hi, I'm using c# vs 2005 win xp pro sp2.

I create a cmd prompt with pInvoke via CreateProcessWithLogonW
Taskmgr shows that cmd instance running as that user.
I type set in that cmd window and it shows me the env vars.
Most importantly, it also shows a custom env var I have set.

Later, I open that proc via
StringDictionary env = myProcess.StartInfo.EnvironmentVariables;
I look at this value in the debugger and all it over shows me is the
standard system env vars.
It never shows me the ones that the process actually has.
It's as though, MS just opens the registry env vars for the user
profile and returns that when myProcess.StartInfo.EnvironmentVariables
is called.

Does anyone know if this is the case?

If so, myProcess.StartInfo.EnvironmentVariables, is lying to us.

Can anyone shed some light?

Thanks.

Aug 13 '07 #1
4 1895
Most importantly, it also shows a custom env var I have set.
This custom environment variable... when and how have you set it?

Marc
Aug 13 '07 #2
ceh
On Aug 13, 9:00 am, "Marc Gravell" <marc.grav...@gmail.comwrote:
Most importantly, it also shows a custom env var I have set.

This custom environment variable... when and how have you set it?

Marc
Via the env block passed into CreateProcessWithLogonW
Sorry, should have clarified that.

Aug 13 '07 #3
ceh
Well, thanks for pointing that out.
As unfortunate as it may be.
I think MS, in this scenario should just return an empty dictionary,
or provide some programmatic info that the env it's returning is not
the processes real env.

I know how to get that info the hard way, It looks like I'm going to
have to take that route.

Thanks.

Aug 13 '07 #4
On 13 Aug., 16:53, ceh <cehup...@gmail.comwrote:
Well, thanks for pointing that out.
As unfortunate as it may be.
I think MS, in this scenario should just return an empty dictionary,
or provide some programmatic info that the env it's returning is not
the processes real env.

I know how to get that info the hard way, It looks like I'm going to
have to take that route.

Thanks.
Hello,

I have the same problem as you. I can't get the env variables that the
process actually has.
I I have noi idea, to get the info.
Do you have actually a solution for this problem?
Could you tell me, how does you solve it?
Could you send me a code snippet ?

Thanks and best regards

Stephan

Aug 17 '07 #5

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

Similar topics

1
by: Heiko Besemann | last post by:
Dear group, I created an aspx page using System.Diagnostics.Process() to launch "tracert" from shell and redirect output to Response.Output which prints it as text/plain into my browsers window....
6
by: danl | last post by:
I need to be able to execute a .bat file from a C# web application I have the following code that compliles and seems to run fine, but the bat file never does it's work...
1
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular I...
1
by: Michael Maes | last post by:
Hi, How would I copy the file 'test.txt' from C:\_A to C:\_B. I need this through the System.Diagnostics.Process-Class and NOT the IO.File-Class p = New System.Diagnostics.Process()...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
1
by: Brad | last post by:
I have an issue trying to execute commands in a web service. The command starts under the specified user. However, it never completes its execution. I can execute simple commands like "echo HELLO"...
1
by: lapucca | last post by:
Hi, I'm using VS 2005, ,.net 2 for C# windows application. I'm using Process to run a C application and redirecting its standard output so I can read it with StreamReader.ReadToEnd. It's only...
2
by: test3 | last post by:
Hello folks, I'm using System.Diagnostics.Process to start a thirdparty program (that works perfectly when started via command line). I'm using Process.StandardOutput to get the output of the...
5
by: Saya | last post by:
Hi Folks, I have now spend app. 3 days to get the below scenario to work, but can not get there! ..Net version = 2.0.50727 Windows version = Microsoft Windows = Windows Server 2003 Now I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.