Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 08, 2016, 12:08:59 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Turn a batch file into an AHK script.  (Read 24228 times)

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #25 on: May 04, 2013, 11:10:50 AM »
Now that was the one we needed. :Thmbsup:

I changed the details in the script for one of my existing VPN's, created a shortcut and placed it in the PPTP toolbar - 1 click on, 1 click off.
The 2 command windows appear as before, the first one disappears almost immediately, the second one shows the changing status of the connection attempt (which is very useful) and disappears once it connects.

I left the cmdow.exe file in the System32 folder which is where I originally put it.

I have set up my 3 most used PPTP VPN's and the only problem I have is an 807 error on one of them, I don't think it's a port problem as all three are from the same provider so the server might be down at the moment.
Although I have not set it up permanently I ran a test with an L2TP connection and that worked fine as well.

Something I realised when I was changing VPN's is there is no indication as to which one is connected, the icon is showing 'PPTPcheck.exe' when I move the cursor over it.
To avoid any problems I have put a shortcut in the toolbar to the OFF batch file, it works for all PPTP connections (L2TP as well) and still only needs one click.
This is probably not necessary but sometimes I finished up with the PPTPcheck icon out of synch with the connection status, a couple of clicks on any ON icon sorts it out but this stops it happening.

As you said this latest script has considerably reduced the number of batch files needed.

If only MS had never removed the icons in the first place!


All the VPN's I use regularly I have accounts for (fortunately free) but I also have bookmarks for another 12 VPN's, 10 PPTP and 2 L2TP and I was surprised to see that the one you used wasn't amongst them.
When I first started using them there were hardly any about and few if any of them were free, now they are popping up all over the place although I'm not sure that I would trust the security of some of them.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #26 on: May 04, 2013, 09:07:19 PM »
Something I realised when I was changing VPN's is there is no indication as to which one is connected, the icon is showing 'PPTPcheck.exe' when I move the cursor over it.

Short term memory loss ?  ;)

EDIT: For some weird reason I can't get the ToolTip to change to something other than the executable name, (I was going to make it the passed NIC name), more reading to be done.

Quote
To avoid any problems I have put a shortcut in the toolbar to the OFF batch file, it works for all PPTP connections (L2TP as well) and still only needs one click.
This is probably not necessary but sometimes I finished up with the PPTPcheck icon out of synch with the connection status, a couple of clicks on any ON icon sorts it out but this stops it happening.

I don't see how that can happen unless you're switching connections faster than the 5 second interval PPTPchek uses between rasdial.exe calls, ie. the longest PPTPchek should be active after a disconnection is 5 seconds.

This was a trade-off between increased CPU usage and a reasonably short update period - there's probably another way I could use to check connection status, (using a WMI or DLL call), but rasdial.exe was quick and easy.  I might look into it a bit further.

Quote
When I first started using them there were hardly any about and few if any of them were free, now they are popping up all over the place although I'm not sure that I would trust the security of some of them.

But since most of them are purely for the purpose of accessing region restricted media content, that shouldn't be a problem.

UPDATE: PPTPchek
  • Start monitor delay will be terminated as soon as the rasdial.exe process terminates.
  • ToolTip now indicates connection name.
« Last Edit: May 04, 2013, 10:39:28 PM by 4wd »

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #27 on: May 05, 2013, 03:48:36 AM »
Quote
Short term memory loss ?  ;)

Brain dead!
Actually I had exploratory brain surgery once.............but they never found anything. :D

The icon being out of sync happened a couple of times when I had a VPN connected and then clicked on another one without closing the first. (Having forgotten which one was connected. :o)
It was always with the icon missing when the next connection became active, clicking on the same shortcut a second time shut everything down, the third time put it back in sync.

I'll try the update later but if the tooltip now shows the connection name it does everything I want. (Unless of course you find a way to incorporate the other two netshell icons to indicate traffic flow.)

While VPN's are useful for the reason you mention I run one all the time, in my view it puts an extra layer between me and the connection's end point which can't be a bad thing.
When I first got interested in them I was in touch with a blogger whose site was all about online privacy and I am still in touch with one VPN provider who I helped with a couple of things when he was getting established.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 6,141
  • Slartibartfarst
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #28 on: May 06, 2013, 06:02:30 AM »
Not sure whether this is relevant at this stage, but instead of using Windows batch commands, you might like to consider using the TakeCommand language. It's based on the Windows command line and batch instructions, but provides a much more powerful instruction set.
I used it some years back and it really was superb.
I only mention it now as it is coming on BitsDJ special offer of 50% at US$49.97. (Click on link.)

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #29 on: May 06, 2013, 07:13:25 AM »
IainB,

Thanks for the suggestion but.......
I am trying to avoid installing any extra software to do what I am trying to do. (AHK was an exception.)
Buying any software is not a consideration.

I have at most half a dozen more things to sort out and I will have achieved everything I am trying to do.
It's not a question of having more ways of doing things but of understanding those that I already have.
There are two main options available to me, AHK and batch files, between them they should cover anything I am likely to want to do.

AHK is like learning German, I know a very small number of words but putting them together into a sentence is largely beyond me.
Batch files are like learning French, I can usually make myself understood but the grammar and the punctuation are all over the place, so what comes out to begin with is not always what I had in mind.

That's where the good people on DC help me out, they can translate my ideas into commands that a computer can understand, which is more than I can sometimes do.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #30 on: May 07, 2013, 10:18:53 AM »
4wd,

I've come back to this due to interest from elsewhere.

I am as happy as it is possible to be with creating batch files to run PPTPchek but I know a lot of people who would not be (able to).
Is there any way that it could be made non-specific, i.e. so that it would run when any PPTP/L2TP VPN is connected and thereby do away with the need for batch files?

As I said this not for me but I said I would ask you in case you felt like looking into it at some time.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #31 on: May 07, 2013, 08:08:39 PM »
Yes, I could just change it so it ran all the time if no arguments were passed.

In that case, with its current method of working, I'd probably have the default interval changed to 10-15 seconds.

EDIT: Or in Win7, there's probably an EventID when a connection is made that you could use to trigger a Scheduled Task.

Here we go, this should work for Vista and later, (including WHS2008+) - requires latest PPTPchek.exe (0.3.0.16):

1) Run Task Scheduler and select Create Basic Task

2013-05-08 14_29_03-Task Scheduler.pngTurn a batch file into an AHK script.

2) Give your task a name, (and a description if you want), then hit Next:

2013-05-08 14_30_23-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

3) Select When a specific event is logged then hit Next:

2013-05-08 14_30_34-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

4) Set up the Trigger as below and hit Next:

2013-05-08 14_31_14-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

5) Choose Start a program, hit Next:

2013-05-08 14_31_22-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

6) Fill out the fields with the appropriate info, hit Next:

2013-05-08 15_26_58-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

7) Hit Finish

2013-05-08 15_27_38-Create Basic Task Wizard.pngTurn a batch file into an AHK script.

Job done!  Program will run when a PPTP connection is made.

(And no, the Task Scheduler in XP isn't intelligent enough to do this.  :) )
« Last Edit: May 08, 2013, 12:45:58 AM by 4wd »

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #32 on: May 08, 2013, 04:42:27 AM »
Like using batch files, I could work that out but most of the people I am thinking of would have no more idea of how to create a scheduled task than they would of how to create a batch file.

Remember that I am lost when it comes to programming so what I am about to say may not be possible.

Network Activity Indicator works for the main network connection(s?) from my point of view it would have been nice if the icon was only visible when a connection was active (but that's just me).
I was thinking in terms of something that worked the same way but only for PPTP/L2TP.

Quote
(And no, the Task Scheduler in XP isn't intelligent enough to do this.  :) )

XP already has automatically appearing icons built in.

Sudden thought! How are the icons triggered in XP? Is it possible to translate that to 7?
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #33 on: May 08, 2013, 11:17:35 AM »
As I have had other things to do I am still using the shortcuts/batch files I set up with the previous version of PPTPchek.
I have been swapping between protocols and VPN's for the last couple of hours checking various things unrelated to this thread and I have made a discovery.
If I start a PPTP VPN from a shortcut/batch file that includes PPTPchek the connection is made and the icon appears.
If the connection then drops the icon disappears, the connection is set to automatically reconnect which is what it is doing but the icon does not reappear.
I have tried it with both the previous and latest versions of PPTPchek although I have not yet had time to try it as a scheduled task which might solve the problem.
I suppose this should have been obvious because it is the batch file that is the trigger not the connection itself.  :-\

I can't read the print in your images even with a magnifier (blurred) , I think I can work most of it out except for what is in the second and third boxes in step 4?
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #34 on: May 08, 2013, 11:24:07 AM »
I can't read the print in your images even with a magnifier (blurred) , I think I can work most of it out except for what is in the second and third boxes in step 4?

Click on the images, they're much bigger than they appear. :)

Or just use PPTPchek.exe 600 in your batch file.
« Last Edit: May 08, 2013, 10:02:38 PM by 4wd »

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #35 on: May 09, 2013, 03:57:20 AM »
OK, I have set up the scheduled task and it works perfectly.
I have recreated shortcuts from Network Connections thereby cutting out the batch files.

I have some questions:

I have found that the icon sometimes remains when I disconnect and the only way to get rid of it is to close the program using the task manager.
(I thought at first this was only if I tried to disconnect shortly after I had connected but it has just done it after being connected for 5 minutes.)

When I close the connection and the icon does disappear it takes about 5 seconds by my reckoning, I am not sure if this is related to the polling delay or a shutdown delay, either way could it be reduced to say 2 seconds?

Does the latest version of PPTPchek replace the previous version if someone is still using batch files or do they work in different ways?

I think I mentioned somewhere that I am in touch with a VPN developer/provider, would you have any objections if details/instructions for PPTPchek were put on his website, it would of course be credited to you?
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi
« Last Edit: May 09, 2013, 04:12:29 AM by pilgrim »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #36 on: May 09, 2013, 05:42:58 AM »
I have found that the icon sometimes remains when I disconnect and the only way to get rid of it is to close the program using the task manager.

Or perhaps right-click on the icon and select Exit?  ;)

Next time it happens please open a CLI and type rasdial.exe and copy the results.  If it says "No connections" then there is a problem.

Quote
When I close the connection and the icon does disappear it takes about 5 seconds by my reckoning, I am not sure if this is related to the polling delay or a shutdown delay, either way could it be reduced to say 2 seconds?

I can change it easily enough but there will be an attendant CPU load increase also, (due to less time in idle state and calling rasdial more often).  Still looking at a better way to get connection state - possibly just by hitting the performance counters.

Quote
Does the latest version of PPTPchek replace the previous version if someone is still using batch files or do they work in different ways?

Replaces, it only requires an optional delay, it will pick up the connection name from what rasdial reports.

Quote
I think I mentioned somewhere that I am in touch with a VPN developer/provider, would you have any objections if details/instructions for PPTPchek were put on his website, it would of course be credited to you?

Not a problem, maybe I'll add a /? so you can get the CLI parameters, (like a normal DOS command).

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #37 on: May 09, 2013, 07:15:32 AM »
Quote
Or perhaps right-click on the icon and select Exit?  ;)

In spite of my fast approaching senility that was the first thing I looked at. :D  No context menu on the icon when this happens!
I also tried a couple of the options we have come up with for cleaning the tray, nothing worked so it would seem the icon is not orphaned.

Quote
Next time it happens please open a CLI and type rasdial.exe and copy the results.  If it says "No connections" then there is a problem.

As soon as I get a minute I will, I can reproduce it if I open and then close a connection fairly quickly, which is how I discovered it. I am guessing there is some sort of delay involved there as well.

Quote
I can change it easily enough but there will be an attendant CPU load increase also, (due to less time in idle state and calling rasdial more often).

At the moment I can't see any CPU load, at least not in the task manager.
As this is only for Windows 7 (don't (want to)) know anything about 8, we are mainly talking about newer computers so resources are less of an issue than they used to be and in this case it seems to be minimal anyway.
If you want to let me have a version set to 2 seconds I'll give it a try. And if there is a delay involved when the program opens perhaps you could reduce that as well?

Quote
Not a problem, maybe I'll add a /? so you can get the CLI parameters, (like a normal DOS command).

Thanks, from the reaction I got when I first mentioned it to my friend I suspect that the lack of an icon is a subject that has come up often so a working solution will help a lot of people. How long has Windows 7 been out?


On a slightly different but connected note:

I have connections to 3 PPTP servers all from the same provider although not the one mentioned previously.
I can connect to 2 of them but the third is giving me an 807 error message all the time.
The developer has checked both the server and my login and cannot find a problem.
I have tried everything from shutting down both the firewall and AV to creating a new connection without a solution.

I have used these connections for several years without a problem and nothing in my set up has been changed.
If the router is passing other PPTP connections it can't be that and the same applies to the firewall and AV.

Can you think of anything I've missed?
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #38 on: May 09, 2013, 10:49:50 AM »
Based on the difference between the last time I posted and when I shut down PPTP I had been on the same connection over 3 hours.
Disconnected, the icon stayed put and I got the following from the CLI:

Quote
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Pilgrim>rasdial.exe
No connections
Command completed successfully.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #39 on: May 11, 2013, 02:32:18 AM »
Quote
Or perhaps right-click on the icon and select Exit?  ;)

In spite of my fast approaching senility that was the first thing I looked at. :D  No context menu on the icon when this happens!
I also tried a couple of the options we have come up with for cleaning the tray, nothing worked so it would seem the icon is not orphaned.

Only thing I can think of is you happening to use rasdial, (to disconnect), at the same instant PPTPchek wants to use it.  I'll put a simple check in to delay PPTPchek if the radial.exe process exists, I've also changed the delay to 2 seconds.

Give it a try and let me know, I'm still looking at another way to get PPTP VPN status that isn't so "hacky".

Quote
I have used these connections for several years without a problem and nothing in my set up has been changed.
If the router is passing other PPTP connections it can't be that and the same applies to the firewall and AV.

Can you think of anything I've missed?

Sorry, can't help you as I rarely use VPNs - closest I get is over a SSH tunnel to my VPS.
No PPTP VPN will work on my Win7 machine currently, (time to reinstall), but a SSH tunnel is damn near bulletproof.

That's why my testing is only on my WHS machine atm.

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #40 on: May 11, 2013, 06:53:10 AM »
The possibility of a clash between rasdial and PPTPchek makes sense because I was using it frequently yesterday to try and track down the server problem I'm having, the majority of the time it worked and there was nothing to indicate why it didn't at times.

I'll test the new version later and let you know.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #41 on: May 12, 2013, 05:16:33 AM »
I have only tested it briefly but the shorter delay in the latest version definitely looks better.
It never got hung up but I need to test it for longer to be certain the problem is solved.

I've now added disconnect commands for both rasdial and the TAP-Win32 Adaptor to my main Internet ON-OFF batch file, cutting out a few more clicks.
I still need to separately shut down any OpenVPN clients I might have running, which I will leave that way.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #42 on: May 13, 2013, 07:53:33 AM »
I have just been switching connections frequently for some time while testing CleanTray, the PPTPcheck icon only hung once and that might not have been due to the program itself.
So it looks like your idea about a clash was most likely right. :)
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #43 on: May 16, 2013, 06:54:25 AM »
It's still hanging now and then but I cannot figure out any consistent factor.

It does not appear to be related to how long the connection has been established nor does it seem to be related to how the connection is disabled - just disconnecting the VPN or shutting down the entire internet connection and associated programs.

Sometimes it will work many times without hanging then it will hang several times in a row.

It is still better than having no indication at all.
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #44 on: May 20, 2013, 05:19:08 AM »
If I create a shortcut to any PPTP/L2TP VPN, in 'properties' they all show the same 'target':
{BA126AD7-2166-11D1-B1D0-00805FC1270E}
I cannot find that anywhere, as a device ID, a file name, or a registry key, so what is it?

In Network Connections under 'Device Name' all PPTP/L2TP VPN's show 'WAN Miniport'.
Is there a way to 'trigger' from that instead of rasdial?

It occurred to me that I can overcome the problem of PPTPchek hanging when I am using my main 'Internet Toggle' batch file by adding a command to exit/kill PPTPchek.
But that does not solve the problem if I shut down the VPN on its own, or if the VPN drops out, and PPTPchek hangs.

Just throwing out some passing thoughts.  :)
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #45 on: May 21, 2013, 02:40:33 AM »
If I create a shortcut to any PPTP/L2TP VPN, in 'properties' they all show the same 'target':
{BA126AD7-2166-11D1-B1D0-00805FC1270E}
I cannot find that anywhere, as a device ID, a file name, or a registry key, so what is it?

It's a CLSID, (Class Identifier), entry in the registry, (look under HKCR\CLSID), for Dial-up Connection Class, ie. the PPTP/L2TP connections are in the same class as dial-up modem connections.

Quote
In Network Connections under 'Device Name' all PPTP/L2TP VPN's show 'WAN Miniport'.
Is there a way to 'trigger' from that instead of rasdial?

I looked at that, as well as Network Performance data for the network but couldn't seem to separate out the VPN stuff from normal LAN connection traffic.

However, I have a new program I'm playing with that seems like it might work OK - it'll run all the time and just appear when a VPN connection is active, then hide again when it isn't.

Unfortunately, now my Win8 netbook doesn't want to make VPN connections, so the only things I'll have to test it against are WHS2011 and XP x86, (even though it won't be used on XP, it should still work).

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #46 on: May 21, 2013, 10:14:43 AM »
When I get back on 7 I'll have a look for that key because I entered the number into the registry search both with and without the brackets and it never found it?

After you suggested an edit to the batch file for 7 to do away with the flag file I have been trying to do the same for XP but it uses devcon not netsh.  :huh:
Is it possible?

7:
netsh interface show interface "Router Connection" | find /i "disabled" >NUL
if errorlevel 1 goto running

XP:
rem Check if our flag file exists and act accordingly
if exist internet_is_on.txt goto running

(devcon *DEV_001C*)
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #47 on: May 22, 2013, 02:29:31 AM »
Okey dokey, back with an all new dang-fangled program that may or may not work.

VPN Indicator a.k.a. VIndicator

Works different to PPTPchek, instead of polling rasdial every so often it just sits back and waits to be told what's happening - a side benefit is virtually no processor usage, (>2% on my netbook).

Start it by just double-clicking on the icon, from that point it just runs in the background.  Works on x86 or x64.
If a PPTP/L2TP VPN is active an icon will show, on disconnect it gets hidden.

Stop it by running it again or choosing Exit from the icon menu when it's visible.

What it does:
1) When first run it checks for other instances of itself, if it finds any it tells it to exit and then exits itself.
2) It sets up a Notification Event on the EventLogs and then waits.
3) When an Event is signaled it fetches the data and if it matches the particular source, (RasClient), and EventIDs, (Vista+ = 20225/20226), it does all the icon-y things.

Because most of the time it spends sitting on its bum I'll look at finding where the network stats are hidden and poll them every 250ms or so, so if they change I can just toggle icons to show activity, (that's the theory anyway).

Haven't tested it on XP, (not really required), but it shouldn't do anything nasty - it'll either indicate something or it won't.

PS.

Code: Text [Select]
  1. devcon status "*DEV_001C*" | find /i "disabled" >NUL
  2. if errorlevel 1 goto running
  3.  
  4. rem Enable device
  5. goto alldone
  6.  
  7. :running
  8. rem disable device
  9.  
  10. :alldone

Update: 0.3.0.30
Changed: No longer requires rasdial.exe to get initial connection
Changed: No longer relies on text within EventLog entry for information
Fixed: If the PC itself runs a VPN server, Event IDs 20267 and 20268 weren't reported.  Now uses Event IDs 20225/20226.
Added: Shows IP in ToolTip

UPDATE: v0.3.0.25
Changed: Logging disabled

v0.3.0.24
Changed: Refined Notification Event which hopefully will reduce load a little
Fixed: Small bug with Quit on Disconnect

v0.3.0.23
Changed: RAS stats polled every 100ms, icon reflects data direction
Changed: Tooltip auto-scales data kB -> PB, removed transfer rate
Removed: Debugging stuff
Added: Windows version check, doesn't run on less than Vista now
Added: Start with Windows option, (HKCU Run)
Added: Checks for Remote Access Service installation - required for MS PPTP/L2TP VPN connections

v0.3.0.20
Fix: Hopefully reports which connection was disconnected rather than username in the log now
Added: Menu item Quit on Disconnection added, setting is saved to .ini for subsequent starts - obviously the icon needs to be visible to select it
Added: Icon toggles if amount of data Rx/Tx changes, only does this every 500ms - any more often increases CPU load
Added: Tooltip shows data Rx/Tx and rate
Maybe: The event checking has been reduced to 2 seconds - CPU load increases the shorter the interval
« Last Edit: July 14, 2013, 01:34:00 AM by 4wd »

pilgrim

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 316
  • Cogito ergo ?
    • View Profile
    • Pilgrim's Page
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #48 on: May 22, 2013, 06:28:56 AM »
Looks good.  :)  I can't change connection at the moment so I'll give it a run later, I just started it up and it showed 0% CPU and slightly under 10MB RAM.
As you say it is not needed in XP.

There is something very weird about that registry key: {BA126AD7-2166-11D1-B1D0-00805FC1270E}
If I search for that in regedit it simply does not appear, if I search for it in a third party program it shows one entry under HKLM and if I tell it to go to the key it opens {BA126AD8-2166-11D1-B1D0-00805FC1270E} ?

Thanks for the devcon script, another one to add to my collection.  :)
I spent 25 years training to be an eccentric then I woke up one morning and realised that I'd cracked it.
I've not had to try since.

I wonder what happens if I click on thi

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: Turn a batch file into an AHK script.
« Reply #49 on: May 22, 2013, 06:43:45 AM »
There is something very weird about that registry key: {BA126AD7-2166-11D1-B1D0-00805FC1270E}
If I search for that in regedit it simply does not appear, if I search for it in a third party program it shows one entry under HKLM and if I tell it to go to the key it opens {BA126AD8-2166-11D1-B1D0-00805FC1270E} ?

I just did a search for the first group of characters:

2013-05-22 21_42_02-Registry Editor.pngTurn a batch file into an AHK script.