Solved

How do I run a VPN Connection .lnk?

Posted on 2010-09-04
9
566 Views
Last Modified: 2012-05-10
I've created a .lnk file that has everything setup, including userID and password.  I need to run this from the task scheduler.

Will the START command work here?  e.g., START as the command with the parameters "" "mylink.lnk" ?

Almost as important is being able to run the VPN.lnk command from a VBS script. I can't seem to initiate a START command from the VBS script, using the Wscript.shell.run command (yes, I can run other things, but not the start command).  not sure why - is it a syntax thing or is START something that can't be run from the VBS script?

Thanks for the help!

Dave
0
Comment
Question by:dlmille
  • 6
  • 3
9 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 33604821
START is part of the CMD prompt, so you need to start cmd first.
However, you cannot use START in conjunction with a .lnk file. You need to start explorer instead:
   explorer test.lnk
will run the commands included in the shortcut file. The same should work from VBS with the run method.
0
 
LVL 41

Author Comment

by:dlmille
ID: 33607326
Qlemo - actually, you can use START in conjunction with a .lnk file.  Try it from the command line - works great.

I tried explorer xxx.lnk with no evidence that it actually worked (I had set up the VPN to prompt for password, and it didn't so for some reason explorer xxx.lnk didn't work)

What I'd like to do is initiate the .lnk from a VBS in a minimized or hidden way.  Initiating a START command somehow in VBS perhaps could work, just can't seem to write the code properly.  START has a way to do that just great, whereas doing a wshell.run "%comspec% whatever.lnk" doesn't seem to work as the CMD.exe doesn't seem to have switches for running hidden or in the background.

When I try wshell.run "start /k whatever.lnk" I get an error file not found.
0
 
LVL 41

Author Comment

by:dlmille
ID: 33607334
The below code:  the %comspec% line works, but pushes a CMD on the stack and creates a visible window that if closed appears to kill the process running the .lnk

The run command with "Start" gives me a cannot find the file error

I thought I could create the string str and run that, but didn't work either...


dim str
Set OWS = CreateObject("WScript.Shell")
str = "Start " & """Title""" & " xxx.lnk"
wscript.echo str
OWS.run "%comspec% /k  XXX.lnk"
OWS.run "Start xxx.lnk"
wscript.echo "Done"
Set OWS = nothing
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 69

Accepted Solution

by:
Qlemo earned 125 total points
ID: 33607992
Sorry, but whenever I run start "" test.lnk, no matter whether the link points to a txt file or contains batch commands or points to a exe, I get the message "This file does not have a program associated with it for performing this action.".
explorer test.lnk however always works.

Anyways, that doesn't help you. The WshShell.Run method as two optional parameters, and the first one is for the Window state. For explanation, see http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx. Using that, one way to start the .lnk is:
   OWS.run "cmd /c XXX.lnk", 0

%comspec% /K doesn't make much sense. /K leaves the DOS prompt open after the command is executed. /c will terminate cmd.exe as soon as the command has finished. You would have wanted a combination of "cmd /c start /min XXX.lnk", maybe, but that will produce a "flashing" cmd window, which vanishes always immediately.
0
 
LVL 41

Author Comment

by:dlmille
ID: 33629981
I believe the ows.run "explorer xxx.lnk",2,0 will work for me.  I've tested it in a test environment and now need to put it in production.  If it works, I'll award points.  If not, I'll come back with the result for more input.
0
 
LVL 41

Author Comment

by:dlmille
ID: 33631410
Indeed, it works.  Thanks alot for your help!
0
 
LVL 41

Author Closing Comment

by:dlmille
ID: 33631439
I was not given the solution (how to run START from task scheduler or from VBS) I was looking for exactly.  However, I was given an alternative (re: use explorer to kick off the lnk file).  The provider did not seem to understand the nuances of the CMD /k and why CMD /c would not work.  I had to try several attempts of the vbscript to understand how to minimize the instance and run to completion, which caused me to look for online references for the .run command to achieve that.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 33631603
Hmm. I gave you the link to understand the RUN method, I explained why your START approach does not work, and that cmd /k doesn't make sense. You never tried to tell why you are so keen on using cmd /k, and so I could not rectify that.

What you have used is a slight variation of my code example. Really, I had more work with verifying your statements and trying to find a solution, than you should have had with implementing my recommendations.

But don't bother, we can leave it at that. Just don't expect to get a ready-to-use solution here all the time, and in particular not for 125 points. Main reason for many Experts to answer on EE is that others can learn how things work, but many weight effort against points nevertheless.
0
 
LVL 41

Author Comment

by:dlmille
ID: 33632397
You made some good points.  CMD /c did not work, while /k did for me and I can't explain why either, except that the VPN process never got kicked off with the /c command.  However, given the points, effort, and the fact that I used your solution re: the explorer.exe command, I would upgrade my assessment/rating if I could.

Thanks for your thoughtful response,

Dave
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
l2tp tunnel from pc to router 14 87
IT Contract Fee 17 148
ASA - RV130 VPN tunnel, cannot pass traffic 8 68
Update Access FrontEnd by Version # 9 43
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you use NetMotion Mobility on your PC and plan to upgrade to Windows 10, it may not work unless you take these steps.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

810 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