ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Turn a batch file into an AHK script.

<< < (5/16) > >>

wr975:
Ever since I started using Windows 7 one of my dislikes was that there was no way to show an icon in the system tray to tell if a PPTP/L2TP VPN was connected, unlike in XP.
-pilgrim (April 29, 2013, 07:16 AM)
--- End quote ---

I had the same problem and tried and errored my way into a basic AHK script I'm using since 2+ years or so (also to learn this script language). I thought about sharing the tool, but I guess it's too strange or complicated. It features different trask tray icons (connected, disconnect, trying to connect), keeps checking for existing PPTP VPN connections and sends a error message if a connection is lost.

It's written for Witopia VPN connections, since Witopia offers plenty of servers to connect to and back then they didn't offer an own connection utility. Now they do, but I still prefer my script. *g*. It can also be used to be "just" a task tray PPTP connection monitor (with optional error message if connection is lost). Read "read me" file to get an explanation. And if all fails, the source might give you some ideas for your own script.

pilgrim:
I spoke too soon. :(

I've spent the last couple of hours trying to put the batch files together and no matter what I try when I combine the PPTPcheck file with the VPN command file I am getting two cmd windows left open every time.
It works alright if I use the separate VPN ON file then run the PPTPcheck file, running VPN OFF shuts everything down, anything beyond that I'm left with open cmd windows.

wr975,

I think you had the right thought, I've just downloaded that and had a look at the script, my first thought was 'I wonder if there's an English version?'


I've given up for the day.

4wd:
Use Cmdow instead of Start - an old standby from the heady days of DOS.

Cmdow - Cmdow is a Win32 commandline utility for NT4/2000/XP/2003 that allows windows to be listed, moved, resized, renamed, hidden/unhidden, disabled/enabled, minimized, maximized, restored, activated/inactivated, closed, killed and more.

eg. cmdow.exe /run /hid pptpchek.exe US-VPN 20

Only the Netload download link seems to be working at this time.

NOTE: Your AV program will probably hate it unless you tell it to ignore it - although MSE and MBAM seem OK with it.

It'll do until I work out how to detach from the CLI, which seems to be surprisingly hard, (or obscure).

pilgrim:
The batch file I started with is this:

if exist pptp-running.txt goto running
rem prog is not running
copy NUL>pptp-running.txt
start /d "C:\Batch Files\PPTP ON-OFF" PPTP-US-ON.bat
start /d "C:\Batch Files\PPTP ON-OFF" PPTPcheck.bat
goto alldone
:running
rem prog is already running
del pptp-running.txt
start /d "C:\Batch Files\PPTP ON-OFF" PPTP-OFF.bat
:alldone

That is running the commands but leaving 2 cmd windows open on enable and 1 cmd window open on disable, so apart from the left-over windows it works.
As I said yesterday, if I run the individual batch files separately the cmd windows disappear as soon as a specific command completes.

Downloaded Cmdow and all my security software ignored it.
Substituted 'start /d', first with 'cmdow' then after looking up the options with 'cmdow /run', in both cases the cmd window flashed on and off, it created the text file but nothing else happened.

For the moment I have put a shortcut to PPTPcheck.bat into the PPTP toolbar so I can start it from there when a VPN is connected and it shuts down automatically when the VPN is disconnected.

I will have another go later, I also have to look into whether all this will work with L2TP given that it requires an additional piece of information in the form of a PSK.

4wd:

--- Code: Text ---rasdial.exe | find /i "no connections" >NULif errorlevel 1 goto runningrem prog is not runningcmdow.exe /run rasdial.exe PPTP-UK freecloudvpn.com 1702cmdow.exe /run /hid PPTPchek.exe PPTP-UK 60goto alldone:runningrem prog is already runningcmdow.exe /run rasdial.exe /disconnect:alldone
Tested working on WHS2011, (equivalent to Win7 x64), running it from the directory in which cmdow.exe, PPTPchek.exe and the batch file all reside.

Run it from a shortcut and no CLI windows are left open.

No separate OFF batch file required, just the ON ones.

(That's a free VPN BTW, password changes every few hours.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version