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

How Can I Map a network drive

Status
Not open for further replies.

rr3news

Programmer
Apr 15, 2003
15
0
0
BR
Hi,
How can I map a netwaork driver with a Visual FoxPro 7 ?

Thanks
 
I save this information off from the UT, and it was written by the late Ed Rauh:

"The Wscript.Network's MapNetworkDrive will take optional user name and password parameters, for example:


oWSHNet = CREATEOBJECT('Wscript.Network')
oWSHNet.MapNetworkDrive('Q:','\\SomeServer\AppShare',.f.,'Foo','Bar')

maps drive Q: to \\SomeServer\AppShare share, does not update the user profile data to auto-map the drive again, using the user id "Foo" and the password "Bar", and this functionality exists in even the version 1 WSH implementation. The first two parameters -m the local device and the share name as a UNC are mandatory. The third parameters is optional, when true, it updates the currently logged-in user profile to auto-map this drive again when logging in. The fourth and fifth parameters are optional user name and password; the Windows Login username and password will be passed if not specified.

The Win32 API's WNetAddConnection3() is more capable, but is a bit of a PITA to implement in VFP - there's sample code showing one approach in my NETRESOURCE class on UT, and ChristofLange wrote a STRUCT class which makes the implementation easier if you don't want to use CLSHEAP for managing the structure memory yourself."

Rick


 
One way is use the windows scripting host. There is lots of information on it at:

msdn.microsoft.com/scripting


I think this is the code you need, but I am referencing a print-out (from the site I gave you) that is several years old.

Unfortunately, I'm on the fly right now and can't try to put something together for you at this time. However, the documentation I have shows:

Set WshNetwork=Wscript.CreateObject("Wsscipt.network")
WshNetwork.MapNetworkDrive "Z:", "\\Server\Share"

* to remove
WshNetwork.RemoveNetworkDrive "Z:"

Again, you'll have to play with connecting this from VFP. It's not all that difficult, but I don't have the time right now. Maybe someone else can provide more immediate feedback?

Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top