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

How to map a network drive 4

Status
Not open for further replies.

HoffaFocus

Technical User
Dec 2, 2000
7
0
0
SE
The client application needs information stored on a server at a certain location and requires that the client computer is mapped to that location with a certain letter, which is used in the client application. Today the client application uses the FILE()-function to check if the mapping is allright and if not the application runs an external bat-file, which first removes the letter (if the computer is mapped to another location with that letter) and then map the computer to the right location with the desired letter. It works but it does not look professional because when running the bat-file the command prompt window is shown. Is there a way to avoid that the command prompt window is shown when running a dos program from foxpro or is there a smarter way of controlling the map letters from foxpro.
 
You might be able to run the batch file without the command window appearing if you set up a batch file and set its Windows properties to always run minimize.

But must you use a drive letter? Can you use UNC notation, as in \\ServerName\Path ?
Robert Bradley
 
Try this WinAPI function:

declare INTEGER WNetConnectionDialog IN WIN32API ;
INTEGER hwnd, ;
INTEGER dwType

=WNetConnectionDialog(0,1)

Good Luck.
 
You can also use the Windows Scripting Host:

*
oNetwork = CreateObject("WScript.Network")
*remove the old drive mapping
oNetwork.RemoveNetworkDrive("Z:",.T.)
*install the new mapping
oNetwork.MapNetworkDrive("Z:", "\\MyServer\MyDir") Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
jonscott8's proposal looks excelent but, how do I solve the server request for user name and password in the proposed script.
 
Regards Robert's star comment, you all deserve stars! but darn if I can figure out how to give a star! Sometimes I feel dumber than a box on rocks. There is nothing on my screen anywhere, how do you vote?. . .am I missing something? (If you think you are starting to get to know this stuff. . .this is the type of thing will make you modest. . .one rock, two rock, three rock, four. . .)is it too obvious for me to see? How do you vote for a contributor/thread?
 
Hanging concentrates the mind!, I figured it out!
 
Hi Hoffafocus,

From the MSDN:

object.MapNetworkDrive strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]

If bUpdateProfile is supplied and its value is TRUE, the mapping is stored in the user profile.

If you are mapping the share point using the credentials of someone other than current user, you can specify strUser and strPassword.
Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top