ON ERROR RESUME NEXT
Err.Clear

Set objShell = CreateObject("WScript.Shell")
objShell.LogEvent 0, "Sample AnyConnect OnConnect script."

Dim strDriveLetter, strRemotePath
strDriveLetter = "REPLACE_WITH_DRIVE_LETTER:"
strRemotePath = "\\REPLACE_WITH_SERVER_NAME\REPLACE_WITH_SHARE"

Set objNetwork = CreateObject("WScript.Network")

' remove old mapping (if any)
objNetwork.RemoveNetworkDrive strDriveLetter

' add new mapping
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

If Err.Number <> 0 Then
objShell.LogEvent 0, "Failed to map network drive." & vbCrLf & Err.Number & ": " & Err.Description
End If

WScript.Quit

OnDisconnect.vbs

ON ERROR RESUME NEXT
Err.Clear

Set objShell = CreateObject("WScript.Shell")
objShell.LogEvent 0, "Sample AnyConnect OnDisconnect script."

Dim strDriveLetter
strDriveLetter = "REPLACE_WITH_DRIVE_LETTER:"

Set objNetwork = CreateObject("WScript.Network")

' remove old mapping (if any)
objNetwork.RemoveNetworkDrive strDriveLetter

WScript.Quit
