Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2004, 06:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Appending to PATH environment variable

Well, I don't quite get it! I am trying to apend to the environment variable PATH using C#, however some things related to this is difficult to find an answer for!

I can retrieve the value of the PATH in two ways, either using direct access to the Windows registry using the RegistryKey class, or using the Environment.GetEnvironmentVariable method. In both cases I will get the expanded value; that is where the %SystemRoot% has been replaced by the actual value. I thought that the method Environment.ExpandEnvironmentVariables was exactly for this purpose!

So the thing is that I can't seem to get the raw value out of the registry, and I need that for writing the new value, since otherwise I would loose the wildcards! How do I do this? Or is there a smarter way of appending to the PATH variable, without doing all this work (checking existency, string concatenation etc.)?

Moreover I have heard that you need to do some kind of broadcast after setting the new variable, something about letting other programs know of the changes! How do I do this, and is there a smart way to do this in C#?

Thanks :)

Jacob.

__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old February 9th, 2004, 10:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I still haven't found the answer. Please help me! I have found this page that more or less describes the functionality that I would like, however the URL is telling me that it is not implemented yet...

http://longhorn.msdn.microsoft.com/l...valuekind.aspx

:(

There must be a way!?

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use variable in path? Shinji XSLT 2 September 18th, 2008 09:08 AM
value from a xml path in a variable ?? TPP XSLT 2 June 23rd, 2006 03:11 AM
Variable Path in web.Config Connection String? ElPato General .NET 4 June 21st, 2004 05:44 PM
Setting environment variable from msi package jacob VS.NET 2002/2003 2 March 25th, 2004 06:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.