?
Solved

Mapping Network dirves after VPN connection

Posted on 2004-08-23
2
Medium Priority
?
372 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 200 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 800 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 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