|
|
|||||||
Hi Stupid question, but... I cant get this to work. Trying to start a shortcut from kix script. The name of the shortcut is "C:\Customer\start vpn connection.lnk". Trying to do the following line: Code:
I get returncode 0..but nothing is happening. If I do the same thing with notepad shortcut or any ordinary applikation it works, but the vpn connection is created from the wizard of my network connections. If I open a command prompt and write "C:\Customer\start vpn connection.lnk" the connection is starting. |
||||||||
|
|
|||||||
Try this instead Code:
|
||||||||
|
|
|||||||
I renamed my shortcut to vpn.lnk so no spaces is the problem. Tried AzzerShaw:s suggestion but with the same result as earlier. Nothing happends and it returns 0. |
||||||||
|
|
|||||||
How about this: Code: Shell '"'+%COMSPEC%+'" /c START "C:\Customer\start vpn connection.lnk"' |
||||||||
|
|
|||||||
No Richard, it doesnt work, it just starts a new command window. Any more idees ? |
||||||||
|
|
|||||||
If I open a command prompt and write "start vpn connection.lnk" the connection is started. If I create a cmd file with one line "start vpn connection.lnk", and try to start this cmd file from explorer it does NOT work. If I start this cmd file from a command prompt it workes. I DONT UNDERSTAND THIS........?????????????!!!!!!!!!! |
||||||||
|
|
|||||||
I think the problem is not with your code, but the fact you are trying to RUN a windows shortcut. I've just run it in a command-window and it runs ok, yet when I try to script it, it fails (it doesn't run). After tinkering around, I found this works... Code:
Obviously replace $PRG with whatever you want to run, it seems that 'START' must be called from a command-window and as such, needs that %COMSPEC% bit. Hopefully this will fix your problem |
||||||||
|
|
|||||||
Arkane, I dident get your suggestion to work, it only left a empty command prompt. But I got this solution to work. Here is my kix code: Code:
The C:\Vpn\Vpn.cmd looks like this: Code:
If I tried to put an Exit in the Vpn.cmd the connection is not working. It seems like the Vpn connection, which is a shortcut from My Networks Connection, needs the command prompt to be open as long as it takes to start the connection..? Well anyway, no it works, the Vpn is connecting, the customer press OK and his terminal server session starts, and then when he logs off he sees one command prompt windows left, that he just close. It is not a perfect solution, but it works. |
||||||||
|
|
|||||||
why you were running with comspec in the first place? is .lnk somekinda "dos-shortcut" I don't know about? if this does not work: shell "myown.lnk" this at least will: shell "explorer myown.lnk" |
||||||||
|
|
|||||||
mima: Sorry about that, I realised my mistake some time later. I had the same problem because I had to actually use the code I pasted in a project and found it didn't work. Running a .cmd is a rather 'unclean' way to do it, particularly as all you want to do is fire up a shortcut - try this (which I know works for me... I tested it this time ) Code:
That handles things with spaces too, however I had to build my '$mypath' variable up from other things due to the way my script handles files/directories (as in I have to append a \ and the filename to the path...) Jokeli: Yeah, a .lnk is a windows shortcut file. You can't run it with explorer.exe unfortunately and for it to work reliably you have to use %COMSPEC% with the /C switch and the 'START' command as well, quite why you need %COMSPEC% I am not sure but it wouldn't work without it. Of course the better thing to do would be to simply be able to 'extract' things from the .lnk file(s) in the first place and then run them directly but you can't do that so easily. |
||||||||
|
|
|||||||
can't? how about: Code:
untested though... |
||||||||
|
|
|||||||
still, I can't compute that you can't exec lnk file... quess I'm getting old... |
||||||||
|
|
|||||||
jokeli, I dont think you getting old...I said earlier in this post Quote: so it works to execute .lnk files, but NOT the one that have been created from My Network Connections. If you look at properties on that it doesnt seems like the other .lnk. In my working code I CAN execute my Rdp.lnk. Code: If $Answer = 1 ; OK I will try your latest suggestion with $shell=createobject("shell.application"). Will be back with the result. |
||||||||
|
|
|||||||
jokeli, I couldnt follow your code... Code: $file = "C:\vpn\vpn.lnk" result = nothing What should happend ? |
||||||||
|
|
|||||||
k, quess the shortcut is not normal. |
||||||||
|
|
|||||||
What kind of VPN is it? Kent |