Solved

Mapping Network dirves after VPN connection

Posted on 2004-08-23
2
368 Views
Last Modified: 2010-07-27
When logging into our Intranet through a VPN connection, I would like to run a program that will map all of the network dirves automatically.  Right now, when I start my computer, the attempted connections fail because I have not connected through the VPN software yet.  After connecting to the Intranet, I then have to manually map the drive that I need to use.

Is there a simple way to do this?
I have Delphi 7 Ent and a Win2K platform.
0
Comment
Question by:ISGDude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Assisted Solution

by:andrewjb
andrewjb earned 50 total points
ID: 11879446
I just use a .bat file with lines like:

net use K: \\server\Admin

and dbl-click this when I've connected.

a similar one with

net use k: /delete

un-maps for me, too.
0
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 200 total points
ID: 11887100
if you have the shares and drives in some configuration file (like an .ini file) you can use these procedures to map the drives

//***Example of call
//*** MapDrive('s:', '\\myserver\public', 'administrator', 'friday13')
procedure MapDrive(const Drive, Share, User, Password:string);
var
  NetResource: TNetResource;
begin
  { fill out TNetResource record structure }
  NetResource.dwType       := RESOURCETYPE_DISK;
  NetResource.lpLocalName  := PChar(Drive);//'S:';
  NetResource.lpRemoteName := PChar(Share);//'\\myserver\public';
  NetResource.lpProvider   := '';

  { map our network drive using our TNetResource record structure }
  If (WNetAddConnection2(NetResource,
                         PChar(Password), {Password (if needed) or empty}
                         PChar(User), {User name (if needed) or empty}
                         CONNECT_UPDATE_PROFILE)<>NO_ERROR) Then
     raise Excepcion.Create('unable to map drive')
  //there are other constants to check the error
  //ERROR_ACCESS_DENIED, ERROR_ALREADY_ASSIGNED, etc
end;

//*** Example of call
//*** UnMapDrive('s:')
procedure UnMapDrive(const Drive:string);
begin
  if (WNetCancelConnection2(PChar(Drive),0,TRUE) <> NO_ERROR) then
    raise Exception.create('Error disconnecting map drive');
end;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question