I was trying to copy some big files over the network to another server, and I mapped the destination drives in the local server for easy copying. However I kept getting errors in my script, which I suspected because the drives getting disconnected. Here is how to set it to not disconnect.
Run as administrator in a command prompt, where -1 means disable.
net config server /autodisconnect:-1