kouchoja
kouchoja

Reputation: 13

Deleting a Path Environment value in a variable with a script.bat on Windows

i created a batch-file for adding a new value in the path with

setx path "%PATH%;C:\Windows\System32\name" /M

Now i tried to delete this former added value also with a batch-file. i tried it with

reg delete "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v Path

but i couldn't find out how to select only "C:\Windows\System32\name" from all the values in Path and delete only this.

Upvotes: 1

Views: 253

Answers (2)

Endoro
Endoro

Reputation: 37589

you can also use pathman from the Windows Server 2003 Resource Kit:

USAGE:

        /as path[;path[;path ...]]
                Adds the semicolon-separated paths to the system path.

        /au path[;path[;path ...]]
                Adds the semicolon-separated paths to the user path.

        /rs path[;path[;path ...]]
                Removes the semicolon-separated paths from the system path.

        /ru path[;path[;path ...]]
                Removes the semicolon-separated paths from the user path.

Upvotes: 1

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200453

You need to remove that path from the value of the variable and then re-assign it:

setx path "%PATH:;C:\Windows\System32\name=%" /m

Upvotes: 0

Related Questions