• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5230
  • Last Modified:

Windows 7 - batch file/script to make MS VPN client connection then map drives...

I have a Windows 7 laptop.  I'd like the user to be able to launch one icon to both connect to the VPN (ms built in vpn client) and then map network drives.

I tried rasdial but it didn't connect.

0
blakogre
Asked:
blakogre
  • 7
  • 6
1 Solution
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
rasdial is correct, but you need a phonebook file first defining a name and protocol to use. You can create that file once with rasphone and a generic name like PPTP or MSVPN, then copy that rasphone.pbk file with your batch file. Then it's just
@echo off
rasdial pptp «User» «Pwd» /domain:«Domain» /phone:«IP-Address» /phonebook:PPTP.pbk
net use * \\server1\share1
...

Open in new window

0
 
blakogreAuthor Commented:
When I type "Rasphone" I get a small gui window with a dropdown, with the VPN connection I created earlier.

That VPN connection already has user/pwd/domain/IP in it...

I still need to include that all in the rasdial line?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
No. If you only need to kick on the connection, you can use
   rasdial «connectionname»
, or
   rasphone -d «connectionname»
rasphone is visibly connecting, while rasdial is "silent".
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
blakogreAuthor Commented:
Ya, and "rasdial "connection name" was giving me incorrect username/pw, when the VPN itself would connect just fine.  so I presumed i was using it incorrectly...
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
rasdial should use the credentials stored in the PBK file. rasphone does without doubt.
0
 
blakogreAuthor Commented:
rasdial seems to be correctly identify the VPN connection, as if i mis-spell it, etc, it lets me know it can't find it.

This is a brand new laptop, so there's nothing else it could be possibly looking at, as no other connections, etc have been set up using that name.

however, it's erroring out with incorrect username/pw

rasdial with the entry name and me manually supplying the u/n p/w also gives same error.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
I'm using rasdial on W2k, XP, Vista, W7 without issues - but I always provide ALL data (gateway, user/pwd, phonebook).

In your last sentence, should that have been rasphone instead of rasdial?
0
 
blakogreAuthor Commented:
rasdial - the command line, non-gui option, meaning, by manuallly - supplying the u/n and pw etc, as part of the command line.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
If you have anything defined on that machine, use rasphone.
I don't know why you have issues with rasdial - providing user and password on the commandline does work in any case I have used or recommended it.
0
 
blakogreAuthor Commented:
the issue with rasphone, is I simply wanted them to launch a bat, connect via vpn, and them have the drives mapped...
0
 
blakogreAuthor Commented:
in that case -- i can just make a shortcut to the VPN connection...
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
I think I get what you mean now. rasphone -d does not dial out (anymore), and when used in a batch file you do not know when the connection is established.

As said, I don't know why rasdial does not work for you. Could you try to provide all info as shown in http:#34944443 ? The phonebook is either "%AppData%\Microsoft\Network\Connections\Pbk\rasphone.pbk" or "C:\Users\All Users\Microsoft\Network\Connections\Pbk\rasphone.pbk".
0
 
blakogreAuthor Commented:
Unfortunately, I no longer have access to this as it is in shipping/transit.  I was not able to resolve it, but I'm presuming it should work for most people.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now