'----------------------------------------------------------------
'- Delay execution for 60 seconds                               -
'- in order to allow other drive mapping mechanisms to complete -
'----------------------------------------------------------------
'WScript.echo "Begin delay"
'WScript.Sleep 30000
'WScript.echo "End delay"


'-----------------------------
'- Get environment variables -
'-----------------------------
Set oShell = CreateObject( "WScript.Shell" )
    domain = oShell.ExpandEnvironmentStrings("%UserDomain%")
    user   = oShell.ExpandEnvironmentStrings("%UserName%")
    comp   = oShell.ExpandEnvironmentStrings("%ComputerName%")

'--------------------------------
'- Open Log file in append mode -
'--------------------------------
Set objFSO      = CreateObject("Scripting.FileSystemObject")
    logFile     = "\\vectorone-its.local\dfs-Root\WebShare\Public-FTP\LogMappedDrives\Log\" & comp & "_" & user & "_" & "MappedDrives.txt"
    Set objFile = objFSO.OpenTextFile(logFile, 8, True)

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives    = WshNetwork.EnumNetworkDrives

For i = 0 to oDrives.Count - 1 Step 2
    xOutString = domain & "," & comp & "," & User & "," & oDrives.Item(i) & "," & oDrives.Item(i+1) & "," & Date & "," & Time & vbCrLf
    objFile.Write xOutString
Next

'------------------
'- Close Log file -
'------------------
objFile.Close
