Windows Environment Variable browsing by tag


Unexpected consequence of Environment Variable change

Saturday, April 16th, 2016

While working on an Azure-bounded .Net project today, I ran into some error that required me to shorten the temp folder path. So I went ahead and changed the default user environment variable value from %USERPROFILE%\AppData\Local\Temp to C:\App\Temp. But before I made the change, I forgot to create the physical path C:\App\Temp first; not sure this is a Windows 10 bug – when I saved the change, the system environment variable editor just let me do it without checking if the path already existed. I strongly believe this should be part of Windows Environment Variables Editor’s enhanced feature to stop user from saving if the path does not exist.

This small omission turned out to be a huge problem – since the temp folder path: C:\App\Temp did not actually exist, it led to all kinds of weird behaviors as listed below:

  • My Visual Studio 2015 would not compile any project
  • My OneNote 2016 suddenly stopped working
  • When I tried to re-install VS 2015 or any program, it would just go into limbo – nothing happened
  • And I could not uninstall any program from the Programs list.
  • All these strange and frustrated Windows behaviors logged no errors into the Event Log so there was no much to go about and find answers by Google search.

Sure, I knew all these bad things were caused by the change of Temp file path, so I quickly restored the original settings – but that did not make these weirdness disappear.

While I was almost at the point to submit a HelpDesk ticket to have IT rebuild my machine, my director came to rescue – he suggested I change the Temp file path again to something like C:\Temp but this time we made sure I create the folder C:\Temp first. Well, after that and a reboot of my machine, everything came back normal and functional as expected.

So, two things worth shouting out loud:

  • Never never change the Windows Environment Variable to point to a path that has not been created yet.
  • For Windows 10 developer, PLEASE PLEASE include some Path.Exist() checking to prevent user from saving the change if the path does not exist yet. Such a simple feature enhancement could play a huge role in enlightening one’s Windows life.