[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Opening dial-up/vpn connection via batch file?

Posted on 2004-11-30
34
Medium Priority
?
790 Views
Last Modified: 2009-12-16
Hi,
  I need to be able to open a dial-up connection window or VPN connection window by double clicking a batch file - can this be done?  I can't seem to find what extension a dial-up connection uses, or how to open it.

Can anyone help?

Cheers

DB
0
Comment
Question by:fsbsupport
  • 14
  • 11
  • 8
  • +1
34 Comments
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12705424
Here's how we did it
create a shortcut on the desktop, and then called the short cut from the batch file
the shortcut will have a .lnk extension
so the  batch file read
start myconnection.lnk
0
 

Author Comment

by:fsbsupport
ID: 12705456
Sorry but that didn't work, if I create a shortcut from a dial-up connection, it states it must be placed on the desktop but I see no file extension under Windows XP, I see all the other file extensions but nothing for this, can you think anything else?

DB
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12705655
I know that connection files have the .rdp extension, I am not sure for VPN, though.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:fsbsupport
ID: 12705675
.rdp files are Remote Desktop protocol (RDP) file extensions aren't they?

DB
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12705721
I am sorry, you are right.
As a second thought, you might want to create an AutoIt3 script, which will be able to create a .exe file, with which you could select the program to open automatically.
0
 

Author Comment

by:fsbsupport
ID: 12705728
How do I do this?

DB
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12705768
Man that worked great in 98 :-(
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12705789
Before trying with AutoIt, are  you sure you tried  stevenlewis' suggestion?
Because, on Windows 2000, you cannot see any apparent extension, but the link created on the desktop is actually a .lnk file: try using 'DIR' command in a DOS shell.
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12705820
I've been messing with it on my xp pro box, and it won't run :-(
0
 

Author Comment

by:fsbsupport
ID: 12705840
No I can't get it to either, just seems to sit there at the DOS window!  Any help would be greatly appreciated!

DB
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12705845
I can drag the shortcut to a cmd box, and it runs ??
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12705879
This is the scripting program I was talking about before:
http://www.hiddensoft.com/autoit3/
With it you can create a script which effectively simulates the CLICKS in a Windows system, as if you were doing it yourself.
I can help you with it, but I need some more details, if you think this is a viable solution.
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12705927
THIS IS MY BATCH FILE
"C:\Documents and Settings\Me\Desktop\test.lnk"
WHERE THE NAME OF THE SHORTCUT IS TEST.LNK
ooops, sorry bout the caps
Now if I double click on it, it opens and closes the cmd box, but it I drag it to a cmd box, it runs
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12705994
This might be the core of the Auto it file:
Run ("C:\Documents and Settings\USERNAME\Desktop\MyLink.lnk")
WinWaitActive("Name of the connection appearing in title bar of the connection window")
Sleep(500)
Send ("!c") ;This sends ALT+c (for connect, if this is the name written on the connect button)
sleep(500)

Obviously you have to compile it to make a .exe file, which does not need any installation.
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706030
found this
http://www.ntcompatible.com/thread29067-1.html
Create a batch file containing these three lines:

rasdial ISPname username password
"C:\Program Files\Internet Explorer\IEXPLORE.EXE"
exit


Notes:

The ISPname must match the name of your dial-up as listed in Network
Connections. username and password as per login for ISP.
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706068
OK, got it to work
cmd /k "C:\Documents and Settings\Me\Desktop\test.lnk"
0
 

Author Comment

by:fsbsupport
ID: 12706322
Is there a way of saying current directory rather than having to type the entire path?  I need to do this command as a batch file for many of our staff to run and each machine will be different?

Thanks
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12706346
Use %CD% in your batch file
0
 
LVL 11

Accepted Solution

by:
elbereth21 earned 2000 total points
ID: 12706359
For example cmd /k "%CD%\file.lnk"
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706399
If the batch file is placed on the desktop (the same dir as the .lnk) then you don't need the path
cmd /k test.lnk
0
 

Author Comment

by:fsbsupport
ID: 12706407
okay, that's working great!  What I now need to do is the following:

After the VPN connection has come up and is running, after say 30 seconds I need to use the following command:

net use X: \\192.168.0.1\sharedrive

This will then map a network drive which is on our internet VPN'd network.

Thanks

DB
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706411
there is one problem with the /k switch, it leaves an open cmd window
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12706468
Use sleep 30 if you installed resource kit
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12706483
Or PING 1.1.1.1 -n 10 -w 1000 >NUL, but be sure to choose a NON-existent IP address
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12706496
Stevenlewis, you can substitute /k, with /c
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706537
the easy way is to create another batch file and tell the user to double click on it after the connection is made
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706560
elbereth21
tried the /c switch, and it closes before executing :-(
0
 

Author Comment

by:fsbsupport
ID: 12706573
That's what we had been doing but we want it as simple as possible, I tried the ping routine and it doesn't work!  After the VPn connection has been both the CMD window stays open as the /C command also doesn't work and the PING command doesn't start - is there another way to sleep it for 30 seconds and then get it to launch another function/procedure?

DB
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706590
While I don't know how to do it, I think this is more appropriate for a wsh file (windows scripting host)
you can pass alot of arguments to it that way
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12706616
/K      Carries out the command specified by string but remains
so it will not execute anything after the string
0
 
LVL 15

Expert Comment

by:ZabagaR
ID: 12708118
Just FYI - in case you still need help:

I set up something VERY SIMILAR a few months ago.  I wish I read this post sooner.

I set a batch file on a few off-site machines to automatically VPN into our main server at a set time each night.
I also had the remote machines map a drive afterwards.

This was actually so I could remotely backup some data on a few servers.

Well, if you still have un-answered questions, let me know.

-z-
0
 
LVL 41

Expert Comment

by:stevenlewis
ID: 12754280
???
0
 
LVL 11

Expert Comment

by:elbereth21
ID: 12780868
Sorry, for being late, I was out of the office these days. Well, fsbsupport, thanks for accepting my answer, but I think it would have been better if you had split the points with stevenlewis, I am sure his suggestions helped you.
0
 

Author Comment

by:fsbsupport
ID: 12780943
sorry, you're right and I wanted to - I just don't know how to.....

DB
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

873 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