Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to map a network drive

How to map a network drive

How to map a network drive

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.

RE: How to map a network drive

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

RE: How to map a network drive

Try this WinAPI function:

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


Good Luck.

RE: How to map a network drive

You can also use the Windows Scripting Host:

oNetwork = CreateObject("WScript.Network")
*remove the old drive mapping
*install the new mapping
oNetwork.MapNetworkDrive("Z:", "\\MyServer\MyDir")

Jon Hawkins
The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed

RE: How to map a network drive

jonscott8's proposal looks excelent but, how do I solve the server request for user name and password in the proposed script.

RE: How to map a network drive

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?  

RE: How to map a network drive

Hanging concentrates the mind!, I figured it out!

RE: How to map a network drive

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
The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close