Solved

Mapping Network dirves after VPN connection

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 103
select query - oracle 16 100
Performance of SQL statement 37 111
How to create virtual printer while installing my application 5 48
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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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