Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-21
13
Medium Priority
?
4,577 Views
Last Modified: 2012-06-21
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
Comment
Question by:blakogre
[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
  • 7
  • 6
13 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 34944443
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
 
LVL 9

Author Comment

by:blakogre
ID: 34944616
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
 
LVL 71

Expert Comment

by:Qlemo
ID: 34944733
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Author Comment

by:blakogre
ID: 34944752
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
 
LVL 71

Expert Comment

by:Qlemo
ID: 34944844
rasdial should use the credentials stored in the PBK file. rasphone does without doubt.
0
 
LVL 9

Author Comment

by:blakogre
ID: 34945071
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
 
LVL 71

Expert Comment

by:Qlemo
ID: 34945092
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
 
LVL 9

Author Comment

by:blakogre
ID: 34946355
rasdial - the command line, non-gui option, meaning, by manuallly - supplying the u/n and pw etc, as part of the command line.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34946905
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
 
LVL 9

Author Comment

by:blakogre
ID: 34947127
the issue with rasphone, is I simply wanted them to launch a bat, connect via vpn, and them have the drives mapped...
0
 
LVL 9

Author Comment

by:blakogre
ID: 34947135
in that case -- i can just make a shortcut to the VPN connection...
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 1000 total points
ID: 34947224
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
 
LVL 9

Author Closing Comment

by:blakogre
ID: 34969960
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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

705 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