Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drive mapping 1

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
I've tried useing WshNetwork.RemoveNetworkDrive, WshNetwork.MapNetworkDrive, Shell('net use Y:'), and ShellWait to map drives with similar results.

Works when stepped through but fails (too disconnect the old drive) in run time.

I thought that the code was just too fast and have tried using sleep to slow it down, but to no avail.

Can you help?
Code:
'    Call ShellWait("net use Y: /d")
'    Call Shell("net use Y: " & SharePath)
    Dim WshNetwork      As Object
    
    Set WshNetwork = CreateObject("WScript.Network")
    WshNetwork.RemoveNetworkDrive "Y:"
    Sleep (2000)

    WshNetwork.MapNetworkDrive "Y:", SharePath

    Set WshNetwork = Nothing


Never knock on Death's door: ring the bell and run away! Death really hates that!
 

Why map drive? You do not need it if you want to access any folder/file on a network.

But instead of using a letter to designate the drive (Y:\) use the name of the drive, ex. \\NtSvr5\MyFolder\

User may already map the 'Y' letter to a drive they need to keep, let's say another CD/DVD drive.

Have fun.

---- Andy
 
Andy,
Thanks for the responce, but I'm looking to re-map drives. No other solution will work for me.
This is to allow current application (not of my design) to continue to be used when users move to other physical locations on the network and need specific drives and not the default.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
WshNetwork.RemoveNetworkDrive "Y:"[!], True[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,
Thanks. Guess I should have looked up the syntax. Thanks or for your help.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Using WshNetwork.RemoveNetworkDrive "Y:", True
I get the error 'Network Connection Does not Exist'.
The drive in question is also not showing with 'EnumNetworkDrives', But its showing in the native windows explorer?

It has me beat again.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
This is part of a login script copied from Tek Tips;
-----------------------------------------------------
' NAME: LogonScript.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' URL : ' Copyright (c) 2003-2007
' DATE : 4/10/2003

'Disconnect any drive mappings as needed.
WSHNetwork.RemoveNetworkDrive "F:", True, True

'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next

'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
-----------------------------------------------------------
May give you a lead or if not lokk at Mark's web link.
The script works on a Windows SBS 2003 setup.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top