Question: I'm using vim 8.1 on windows.
The IT department has set $HOME to a slow network drive.
Every time a file gets written to $HOME vim slows down.

I have $VIM/vimrc with the following content.

```
let $HOME = $USERPROFILE

```

This used to work, but now netrw still creates files on the network drive.

How do I change $HOME so that no slowdown occurs?

Answer: 
After you answered the question yourself, the focus shifted. It seems the Question is now "How can I prevent Vim from checking for `$HOME/_vimrc`?".

Try the following:

* Create the file `$USERPROFILE/vimrc` with all your configuration.
* Create the environment variable `VIMINIT` with the value `source $USERPROFILE/vimrc`.

On startup the variable `VIMINIT` is checked first. If it is set, the value of `$VIMINIT` is used as an Ex command line. 

---

Update (I know that the questioner is not interested anymore):

You should also check your `runtimepath`. Most likely it still points to `$HOME/vimfiles` (on Windows). So you should create the directory `$USERPROFILE/vimfiles` to store extended configuration and plugins etc.

At the beginning of `$USERPROFILE/vimrc` you have to fix the `runtimepath`. 
I would try it like this:

```
set runtimepath-=~/vimfiles
set runtimepath^=$USERPROFILE/vimfiles
set runtimepath-=~/vimfiles/after
set runtimepath+=$USERPROFILE/vimfiles/after

```

**After that** you should still change `$HOME`, as others (like netrw) still uses it.

```
let $HOME=$USERPROFILE

```

I'm on Linux, so someone should test this on Windows.
This is @Ralf's answer but with implementation steps tested on Windows 10 with gVim 9.0. By "tested", I just mean gVim now opens and closes immediately with my `_vimrc` settings, so it appears to be ignoring that IT set $HOME to a slow network drive.

1. Create file `$USERPROFILE/_vimrc` with your regular configuration
2. Add this section to the very start of your `_vimrc`:

```
 set runtimepath-=~/vimfiles
 set runtimepath^=$USERPROFILE/vimfiles
 set runtimepath-=~/vimfiles/after
 set runtimepath+=$USERPROFILE/vimfiles/after
 let $HOME = $USERPROFILE
 if getcwd() ==? $HOMEDRIVE . $HOMEPATH
   :cd $USERPROFILE
 endif

```
3. Create user environment variable `VIMINIT` with the value `source $USERPROFILE/_vimrc`.

	* For a non-admin user account, set these under *Control Panel* → *User Accounts* → *Change my environment variables*
	* If running gVim causes `Error detected while processing VIMINIT: E484: Can't open file C:\Users\<username>/vimrc`, then double-check the environment variable filename exactly matches the actual file. For example, maybe there's an underscore at the start of only one reference.

Explanation
===========

See @Ralf's answer for most of the explanation. Concerning the `if` statement I added, it is because vim Start Menu shortcuts are installed with the *Start in:* argument set to `%HOMEDRIVE%%HOMEPATH%`.

* If vim is launched from the Start Menu shortcuts, then `:cd $USERPROFILE` overwrites the working directory.
* If vim is launched by double-clicking a file in Windows Explorer, then don't change the working directory.
* If vim is launched from the command prompt, then don't change the working directory -- unless the command prompt path happens to equal `%HOMEDRIVE%%HOMEPATH%`, which hopefully isn't common for you. Otherwise I believe your only option is changing the existing Windows environment variables, which may be against your IT's wishes.
* Check the current working directory by running `:pwd` and/or listing the current directory contents with `:e`  ("e" and a space) then pressing `Ctrl`+`D`. I do have `set autochdir` in my `_vimrc`, and it still works as expected.
[![Properties of shortcut in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Vim 9.0](https://i.stack.imgur.com/2wUtB.png)](https://i.stack.imgur.com/2wUtB.png)

Lastly, arguably `$HOMEDRIVE = $SystemDrive` should also arguably be added to the `_vimrc`. After all, most people would expect $HOME and $HOMEDRIVE to go together. However while the Windows shortcuts clearly use it, I'm not sure anything within vim itself uses it. I removed it from my config after deciding it wasn't worth it.