tags:

views:

209

answers:

1

I wrote the following javascript to put in my startup folder to work around some problems with mapping drives. Unfortunately it has the side effect of starting command prompts with H:\ as 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");
+1  A: 

I actually worked this out from the suggested alternative questions, but it was different enough I thought I'd finish posting and answer my own question.

Bascially, the %HOMEDRIVE% was set to H:\, but since H:\ did not exist before I wrote my script, it wasn't getting set in the command prompt.

You can add an Autorun to the command prompt to change to C: (or wherever) before it starts. More details here: http://windowsxp.mvps.org/autoruncmd.htm

Colin Pickard
I suspected something like this. +1 for finding out. :-)
Tomalak