|
-
Mar 27th, 2009, 01:59 PM
#1
Thread Starter
New Member
Changing the Path (environment variable) under VISTA with VB
Hi, i need to change the "PATH" environment variable in a VB program (Visual Studio 2008). Here is the code i use to add the "C:\TEST\" folder at the end of the existing one.
test Code:
Dim PathVal As String
PathVal = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)
Environment.SetEnvironmentVariable("Path", PathVal & ";C:\TEST\", EnvironmentVariableTarget.User)
It work great under Windows XP but under Vista it did'nt work at all (even when running as a administrator).
How can i change the "PATH" under Vista?
Thanks in advance...
-
Mar 27th, 2009, 02:23 PM
#2
Re: Changing the Path (environment variable) under VISTA with VB
I know this might not help but according to MSDN it 'should' work.
However there is an example here http://msdn.microsoft.com/en-us/library/z46c489x.aspx
-
Mar 27th, 2009, 02:35 PM
#3
Thread Starter
New Member
Re: Changing the Path (environment variable) under VISTA with VB
By the way it's not even the "SetEnvironmentVariable" that give me a error it's the "GetEnvironmentVariable"...
Let's take this bit of code for exemple:
Code:
Dim PathVal As String
On Error GoTo FinTrt
PathVal = System.Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User)
FinTrt:
If Err.Number <> 0 Then
MSGBOX(Err.Description)
Else
MSGBOX("OK")
End If
Under XP i receive "OK" and under VISTA here his the error (Soory for the french error but the Vista is a french one)
"La référence d'objet n'est pas définie à une instance d'un objet."
Thanks again...
-
Mar 27th, 2009, 03:16 PM
#4
Re: Changing the Path (environment variable) under VISTA with VB
is it possible that the language is the problem? What's the french word for "Path" ???? just taking a stab in the dark here.
-tg
-
Mar 27th, 2009, 03:19 PM
#5
Thread Starter
New Member
Re: Changing the Path (environment variable) under VISTA with VB
I don't think the language is the problem because the XP one is in French too and work perfectly.
-
Mar 27th, 2009, 03:42 PM
#6
Re: Changing the Path (environment variable) under VISTA with VB
Ah.. ok, well, there goes that theory then.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|