jemz
jemz

Reputation: 5153

How to unset PATH?

I know it is possible to set PATH programmatically with using for example

SET PATH=%PATH%;C:\wamp\bin\php\php5.4.16\

But how can I unset PATH programmatically?

The reason why I want to unset PATH is that I could not rename my text file because it will show this error.

The action cannot be completed because the file is open in php.exe

Upvotes: 2

Views: 5359

Answers (2)

Noodles
Noodles

Reputation: 2011

You just set a new path

path c:\windows\system32;c:\windows;c:\windows\system32\wbem

which is system standard path.

You can use set to remove C:\Program Files\Debugging Tools for Windows from path.

`set path=%PATH:C:\Program Files\Debugging Tools for Windows=%`

watch out for trailing semi colons.

Though it's unlikely to help your specific problem.

The formatting has fucked up, make sure you put =% on the end of the line.

Upvotes: 0

Mofi
Mofi

Reputation: 49216

It is possible to unset PATH in a command prompt window or in a batch file for everything started from within this command interpreter process after doing that.

The possible commands are set PATH= or path ; as explained in help of command path output in a command prompt window after entering path /? or help path.

But PATH is not unset for any process already running and for new process started not from within this command interpreter process.

To remove PATH is a good method for testing a batch file which should be executed by Windows task scheduler. If nothing in the batch file depends on PATH, the probability is high that it works also with Windows task scheduler running with a different account/credentials.

But in your case of being not able to rename a text file as being currently opened by php.exe, it is of no use to unset PATH. Terminate PHP process and rename the file, or restart Windows which results also in terminating PHP process and rename the file after Windows started again.

Upvotes: 2

Related Questions