Solved

Mapping Network dirves after VPN connection

Posted on 2004-08-23
2
362 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now