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
Solved

Mapping Network dirves after VPN connection

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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