Board index » Visual Studio » Remove from Environment Path

Remove from Environment Path

Visual Studio359
I some code for Visual Basic that I can compile into an executable that will

allow me remove part of the the environment path for WinXP, Win2000, and

WinNt.



If Environment path is

c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2



I need a utility that I can run via command prompt



RemovePath.exe c:\removeme

or

RemovePath.exe c:\removeme2



this will modify the registry to permanently remove the c:\removeme from the

environment path



Anyone have or know of a a utility (preferred) or code?


-
 

Re:Remove from Environment Path

On Wed, 25 Jan 2006 07:00:03 -0800, "molonede" <molonede@discussions.microsoft.com>wrote:



¤ I some code for Visual Basic that I can compile into an executable that will

¤ allow me remove part of the the environment path for WinXP, Win2000, and

¤ WinNt.

¤

¤ If Environment path is

¤ c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2

¤

¤ I need a utility that I can run via command prompt

¤

¤ RemovePath.exe c:\removeme

¤ or

¤ RemovePath.exe c:\removeme2

¤

¤ this will modify the registry to permanently remove the c:\removeme from the

¤ environment path

¤

¤ Anyone have or know of a a utility (preferred) or code?



Try using the SetX utility:



http://www.microsoft.com/downloads/details.aspx?FamilyID" rel="nofollow" target="_blank">www.microsoft.com/downloads/details.aspx=dc2d3339-8f36-4fba-a406-2a2a2ad7208c&displaylang=en

technet2.microsoft.com/WindowsServer/en/Library/9e0748f8-5c67-4dc4-b8dc-11a8481d86331033.mspx">technet2.microsoft.com/WindowsServer/en/Library/9e0748f8-5c67-4dc4-b8dc-11a8481d86331033.mspx





Paul

~~~~

Microsoft MVP (Visual Basic)

-

Re:Remove from Environment Path



"molonede" <molonede@discussions.microsoft.com>wrote in message

Quote
I some code for Visual Basic that I can compile into an executable that

will

allow me remove part of the the environment path for WinXP, Win2000, and

WinNt.



NT stores its environment path in the registry? That is a new one on me.

In any event, why use a VB program to do this? Seems like an odd choice.



Quote


If Environment path is

c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2



I need a utility that I can run via command prompt



RemovePath.exe c:\removeme

or

RemovePath.exe c:\removeme2



this will modify the registry to permanently remove the c:\removeme from

the

environment path



Anyone have or know of a a utility (preferred) or code?





-

Re:Remove from Environment Path

Thanks, but that doesn't help me. There is nothing in the setx utility to

remove a portion of the string. I also can not install the utility on the

workstation, I just need an executable that I can run on a workstation. I

have about 500 workstations that I am needing to modify and each workstations

PATH is different, except that they will have a directory in the path that

needs to be removed.



One workstation would have

PATH=c:\winnt\system32;c:\removeme;c:\keepme

Another workstation would have

PATH=c:\win2000\system32;c:\removeme;c:\keepme2;c:\keepme



So I need a stand alone utility that I can run on workstations that would

remove the passed parameter from the PATH

ex.

c:\removepath.exe "c:\removeme"



would result in

One workstation would end up having

PATH=c:\winnt\system32;c:\keepme

Another workstation would end up having

PATH=c:\win2000\system32;c:\keepme2;c:\keepme





"Paul Clement" wrote:



Quote
On Wed, 25 Jan 2006 07:00:03 -0800, "molonede" <molonede@discussions.microsoft.com>wrote:



¤ I some code for Visual Basic that I can compile into an executable that will

¤ allow me remove part of the the environment path for WinXP, Win2000, and

¤ WinNt.

¤

¤ If Environment path is

¤ c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2

¤

¤ I need a utility that I can run via command prompt

¤

¤ RemovePath.exe c:\removeme

¤ or

¤ RemovePath.exe c:\removeme2

¤

¤ this will modify the registry to permanently remove the c:\removeme from the

¤ environment path

¤

¤ Anyone have or know of a a utility (preferred) or code?



Try using the SetX utility:



http://www.microsoft.com/downloads/details.aspx?FamilyID" rel="nofollow" target="_blank">www.microsoft.com/downloads/details.aspx=dc2d3339-8f36-4fba-a406-2a2a2ad7208c&displaylang=en

technet2.microsoft.com/WindowsServer/en/Library/9e0748f8-5c67-4dc4-b8dc-11a8481d86331033.mspx">technet2.microsoft.com/WindowsServer/en/Library/9e0748f8-5c67-4dc4-b8dc-11a8481d86331033.mspx





Paul

~~~~

Microsoft MVP (Visual Basic)



-

Re:Remove from Environment Path

You may be right, not sure. But I would want the utility to handle WinXP,

Win2000, and WinNT.



"David J Mark" wrote:



Quote


"molonede" <molonede@discussions.microsoft.com>wrote in message

news:937F2A8C-3F14-443B-9AEB-5C3C86DC9C0D@microsoft.com...

>I some code for Visual Basic that I can compile into an executable that

>will

>allow me remove part of the the environment path for WinXP, Win2000, and

>WinNt.



NT stores its environment path in the registry? That is a new one on me.

In any event, why use a VB program to do this? Seems like an odd choice.



>

>If Environment path is

>c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2

>

>I need a utility that I can run via command prompt

>

>RemovePath.exe c:\removeme

>or

>RemovePath.exe c:\removeme2

>

>this will modify the registry to permanently remove the c:\removeme from

>the

>environment path

>

>Anyone have or know of a a utility (preferred) or code?







-

Re:Remove from Environment Path

You have to read in the path member under



HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session

Manager\Environment



make the replacement, then write it out again and reboot.



--



Randy Birch

MS MVP Visual Basic

vbnet.mvps.org/">vbnet.mvps.org/



Please reply to the newsgroups so all can participate.









"molonede" <molonede@discussions.microsoft.com>wrote in message

:I some code for Visual Basic that I can compile into an executable that

will

: allow me remove part of the the environment path for WinXP, Win2000, and

: WinNt.

:

: If Environment path is

: c:\winnt\system;c:\removeme;c:\keepme;c:\removeme2

:

: I need a utility that I can run via command prompt

:

: RemovePath.exe c:\removeme

: or

: RemovePath.exe c:\removeme2

:

: this will modify the registry to permanently remove the c:\removeme from

the

: environment path

:

: Anyone have or know of a a utility (preferred) or code?



-

Re:Remove from Environment Path

On Wed, 25 Jan 2006 08:38:03 -0800, "molonede" <molonede@discussions.microsoft.com>wrote:



¤ Thanks, but that doesn't help me. There is nothing in the setx utility to

¤ remove a portion of the string. I also can not install the utility on the

¤ workstation, I just need an executable that I can run on a workstation. I

¤ have about 500 workstations that I am needing to modify and each workstations

¤ PATH is different, except that they will have a directory in the path that

¤ needs to be removed.

¤

¤ One workstation would have

¤ PATH=c:\winnt\system32;c:\removeme;c:\keepme

¤ Another workstation would have

¤ PATH=c:\win2000\system32;c:\removeme;c:\keepme2;c:\keepme

¤

¤ So I need a stand alone utility that I can run on workstations that would

¤ remove the passed parameter from the PATH

¤ ex.

¤ c:\removepath.exe "c:\removeme"

¤

¤ would result in

¤ One workstation would end up having

¤ PATH=c:\winnt\system32;c:\keepme

¤ Another workstation would end up having

¤ PATH=c:\win2000\system32;c:\keepme2;c:\keepme



No can do. The complete path has to be replaced and reset since the system global environment

variables are loaded into memory. You can read it, modify it and then reset it.



If you don't want to use the SetX utility see the following:



How to propagate environment variables to the system

support.microsoft.com/kb/q104011/">support.microsoft.com/kb/q104011/



How To Use the Registry API to Save and Retrieve Settings

support.microsoft.com/kb/q145679/">support.microsoft.com/kb/q145679/



Also keep in mind that system global environment variables are handled differently in the Window

ME/9x versions.





Paul

~~~~

Microsoft MVP (Visual Basic)

-