Here's a very simple script that unmaps all drives:
'Start of Code
Set objNetwork = CreateObject("WScript.Network")
Dim AllDrives: Set AllDrives = objNetwork.EnumNetworkDrives()
IF NOT AllDrives.Count = 0 THEN
For i = 0 To AllDrives.Count - 1 Step 2
objNetwork.RemoveNetworkDrive AllDrives.Item(i), TRUE, TRUE
Next
END IF
Wscript.Echo "Unmapped all drives."
'End of Code
The script works fine MS Windows Server 2003 SE SP2. But when I run it on MS Windows Server 2003 SE SP1, I got this error:
Error: The parameter is incorrect.
Code: 80070057
Source: WSHNetwork.RemoveNetworkDrive
I tried modifying the arguments. Stored them in variables. Excluding them (except the drive letter) but I still get the same error. Any insights?