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

Maping a network drive with password

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Anybody.

Can VFP map a network drive and pass a password parameter? if so... how?

Hope someone can help me.
-manny
 
This is the code that I use to do this; hope it helps :)

LOCAL loShell, loFolder, lcResource, lcPassword, lcDriveLetter, lcUserName, lcPassword

loShell = CREATEOBJECT("Shell.Application")
loFolder = loShell.BrowseForFolder(0, "Select directory: ", 0 )


DO CASE

CASE TYPE("loFolder")="O"

IF TYPE("loFolder.Items.ITEM")="O"

IF TYPE("loFolder.Items.ITEM.PATH") == "C"

lcResource = loFolder.Items.ITEM.PATH
lcResource=ALLTRIM(lcResource)

IF NOT SUBSTR(lcResource,1,LEN(lcResource))=="\"

lcResource=lcResource+"\"

ENDIF

lcPassword = ""
lcDriveLetter = "F:"
lcUserName = "Guest"
lcPassword = "Guest"

loNet=CREATEOBJECT("WScript.Network")

IF TYPE("loNet") == "O"

*!* U'll need here some coding to trap erros
loNet.mapNetworkDrive(lcDriveLetter,lcResource,1,lcUserName,lcPassword)

ENDIF

ENDIF

ENDIF

ENDCASE

*!* For more infos look in MSDN (WshNetwork.MapNetworkDrive)
RELEASE loShell, loFolder, lcResource, lcPassword, lcDriveLetter, lcUserName, lcPassword Thanks for sharing your knowlege.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top