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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BrowseForFolder to map a network drive? 1

Status
Not open for further replies.

cbsarge

IS-IT--Management
Jun 20, 2001
219
US
I want to use the BrowseForFolder function to map a network drive. Can this be done?
Code:
Set objShellApp = CreateObject ("Shell.Application") 
Set objMyComputer = objShellApp.NameSpace (&H11&) ' My Computer constant 
Set objFolder = objShellApp.BrowseForFolder (0, "Browse to the desired folder", 0)
Set objNetwork = CreateObject("WScript.Network") 
strDriveLetter = "S:" 
objNetwork.MapNetworkDrive strDriveLetter, objFolder
This doesn't work because the value you end up with is:
Code:
"C:\Documents and Settings\user\NetHood\share on server"
not:
Code:
"\\server\share"
Any ideas?
Thanks!

[!]The AutoSavers![/!] [2thumbsup]
 
Instead of using objFolder have you tried objFolder.Self.Path ?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
That did it - thanks!

Here is the complete code for anyone else:
Code:
Set objShellApp = CreateObject ("Shell.Application") 
Set objMyComputer = objShellApp.NameSpace (&H11&)
Set objFolder = objShellApp.BrowseForFolder (0, "Browse to the desired folder", 0)
Set objNetwork = CreateObject("WScript.Network") 
strDriveLetter = "S:" 
objNetwork.MapNetworkDrive strDriveLetter, objFolder.Self.Path

[!]The AutoSavers![/!] [2thumbsup]
 
I'm glad that worked for you.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top