简体   繁体   中英

Windows Path Environment Variable

Forgive me for putting multiple questions in one post, but I assume these are all easy to answer. I've become somewhat proficient at using the command line and setting environment variables on my Windows 8.1 machine. However, I still have a few questions about the %PATH% variable:

  1. Can you name the same directory twice in %PATH% ?
  2. If you delete a directory that was mentioned in %PATH% (say with File Explorer), will its entry in %PATH% be deleted?
  3. If not, will an error result when the OS searches for a non-existent directory?
  4. If the %PATH% variable is deleted, will the OS crash? And how can you restore its value at that point?
  5. When a directory in %PATH% is searched for executables, are all of its subdirectories searched also?

Thanks in advance!

  1. Yes you can have duplicate entries, but it would not achieve anything. The PATH is scanned to find a file and stops at the first instance it finds so having the same path multiple times will just waste time if anything (odds are the logic will remove duplicates when scanning)
  2. No, at least not automagically. some install/un-install scripts will do this for you but otherwise it will just be there cluttering you PATH variable.
  3. No, it will just never find anything in there.
  4. No because the processes that are already started will have a copy of the environment from when they started it will only affect new processes, or when you restart. (If you want to test this, start a command window, then change the user path by adding something, and see if it is there in the already opened command window, then open a new window and see that the change is present).
  5. No all sub directories are not searched

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM