|
Error 424 is object required. Try this: Option Explicit ‘On Error Resume Next Dim objWshNet Set objWshNet = Wscript.CreateObject(“WScript.Network”) Dim objDrvs Set
objDrvs =
GetObject("winmgmts:").InstancesOf("Win32_NetworkConnection") Dim
obj Dim
strDrive Dim
strDMapping for
each obj in objDrvs
strDrive = obj.LocalName
strDMapping = obj.RemoteName
On Error Resume Next
objWshNet.RemoveNetworkDrive strDrive, True, True 'Force removal
If Err<>0 Then
'Log Error
Wscript.Echo "Error disconnecting"& strDrive
Err.Clear
End If
objWshNet.MapNetworkDrive strDrive, strDMapping
If Err<>0 Then
'Log Error
Wscript.Echo "Error remapping "& strDrive
& "("& strDMapping &")"
Err.Clear
Else
Wscript.Echo "Remapped "& strDrive & "("&
strDMapping &")"
End If Next Thanks, c - 312.731.3132 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jacqui Hurst 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 objDrvs
strDrive = obj.LocalName
strDMapping = obj.RemoteName
On Error Resume Next
objWshNet.RemoveNetworkDrive strDrive, True, True 'Force removal
If Err<>0 Then
'Log Error
Wscript.Echo "Error disconnecting"& strDrive
Err.Clear
End If
objWshNet.MapNetworkDrive strDrive, strDMapping
If Err<>0 Then
'Log Error
Wscript.Echo "Error remapping "& strDrive
& "("& strDMapping &")"
Err.Clear
Else
Wscript.Echo "Remapped "& strDrive & "("&
strDMapping &")"
End If Next The
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. Cheers Jacqui |
- Fwd: RE: [ActiveDir] OT: Vbscript to disconnect and reconnec... Jacqui Hurst
- RE: [ActiveDir] OT: Vbscript to disconnect and reconnec... Brian Desmond
