set objwshnet = CreateObject("wscript.network") might work for you ;0)
M@
On 4/26/06,
Jacqui Hurst <[EMAIL PROTECTED]> wrote:
I am trying to write a quick and dirty script for a test lab which will disconnect and reconnect persistent drive mappings. The script is as follows:Set objDrvs = GetObject("winmgmts:").InstancesOf("Win32_NetworkConnection")for each obj in objDrvsstrDrive = obj.LocalNamestrDMapping = obj.RemoteNameOn Error Resume NextobjWshNet.RemoveNetworkDrive strDrive, True, True 'Force removalIf Err<>0 Then'Log ErrorWscript.Echo "Error disconnecting"& strDriveErr.ClearEnd IfobjWshNet.MapNetworkDrive strDrive, strDMappingIf Err<>0 Then'Log ErrorWscript.Echo "Error remapping "& strDrive & "("& strDMapping &")"Err.ClearElseWscript.Echo "Remapped "& strDrive & "("& strDMapping &")"End IfNextThe script fails to disconnect any drive mapping and therefore fails to reconnect it. Can anyone advise me where I am going wrong? The ERR value is 424 is that make any sense to anyone. I want to run this on logon but I just running it interativley at the moment.CheersJacqui
