WSH Mapping Drives keep the default set of paths
I wrote the following javascript to put in my startup folder to work around some drive mapping issues. Unfortunately it has the side effect of running commands with H: \ as the current directory. How can I get around this?
var objNetwork = WScript.CreateObject("WScript.Network");
/* Remove Network Drives */
try {
objNetwork.RemoveNetworkDrive("H:", true, true);
} catch (e) {}
try {
objNetwork.RemoveNetworkDrive("Y:", true, true);
} catch (e) {}
try {
objNetwork.RemoveNetworkDrive("Z:", true, true);
} catch (e) {}
/* Recreate Network Drives */
objNetwork.MapNetworkDrive ("H:", "\\\\server1\\home", false);
objNetwork.MapNetworkDrive ("Y:", "\\\\server2\\source", false, "user", "pass");
objNetwork.MapNetworkDrive ("Z:", "\\\\server3\\source", false, "user", "pass");
0
source to share
1 answer
I actually worked it out from the suggested alternate questions, but it was completely different, I thought I'd finish posting and answer my own question.
Bascially,% HOMEDRIVE% was set to H: \, but since H: \ didn't exist before I wrote my script, it didn't make it to the command line.
You can add autorun to the command line to navigate to C: (or elsewhere) before starting it. More details here: http://windowsxp.mvps.org/autoruncmd.htm
+2
source to share