/bundles/itninjaweb/img/Breadcrumb_cap_w.png
Hi all

I have an application that needs to have a certain driveletter mapped to a certain UNC path.
Map I:\ to \\<servername>\<foldername>
In most cases the users have this driveletter mapped to the correct source. But if they don't I want to map it.

I need a script that check
If I: is mapped
If I: is mapped, check if it is mapped to the correct server and folder.
If I: is mapped to the correct - then OK
If I: is mapped, but not to the correct server and folder - disconnect drive and connect to correct server and folder
If I: is not mapped - connect to correct server and folder.


I have found a script for disconnecting and connecting drives so this should be OK.
What I haven't been able to solve so far is how to resolve the UNC of a mapped drive and run a check against this string.

Can anyone help me with this?

br
andler
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

-1
Something like this?

On Error Resume Next

Const sMYDRIVE = "J:"
Const sMYUNC = "\\127.0.0.1\d$"

Set oWSN = CreateObject("WScript.Network")
Set oDrives = oWSN.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2

If oDrives.Item(i) = sMYDRIVE Then sUNC = LCase(oDrives.Item(i+1))

Next

If sUNC = LCase(sMYUNC) Then

Msgbox "OK"

Else

oWSN.RemoveNetworkDrive sMYDRIVE, True

oWSN.MapNetworkDrive sMYDRIVE, sMYUNC

End If

Set oDrives = Nothing
Set oWSN = Nothing

Please note that I haven't tested this... I've no idea whether it'll work!
Answered 09/07/2005 by: WiseUser
Fourth Degree Brown Belt

Please log in to comment
0
Hi WiseUser

Thanks for guiding me.

I had to make some small changes to your script in order to make it work.
I guess thats part of your idea, make me think.

If you have any comments to my changes please let me know.

br
andler


***********************************************
On Error Resume Next

Dim objDrives, fldr, i

Const sMYDRIVE = "i:"
Const sMYUNC = "\\hank\info"

Set objDrives = wshNetwork.EnumNetworkDrives

For i = 0 to (objDrives.Count - 1) Step 2

If objDrives.Item(i) = sMYDRIVE Then

fldr = LCase(objDrives.Item(i+1))

If sMYUNC <> fldr Then
wshNetwork.RemoveNetworkDrive sMYDRIVE, True
wshNetwork.MapNetworkDrive sMYDRIVE, sMYUNC
End If

Else

wshNetwork.RemoveNetworkDrive sMYDRIVE, True

wshNetwork.MapNetworkDrive sMYDRIVE, sMYUNC

End If

Next
Answered 09/08/2005 by: andler
Orange Belt

Please log in to comment
0
If objDrives.Item(i) = sMYDRIVE Then

Remember that comparisons are case-sensitive... if "objDrives.Item(i)" is "I:", the above statement will be false.[;)]
Answered 09/08/2005 by: WiseUser
Fourth Degree Brown Belt

Please log in to comment