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.

<< < (4/16) > >>

4wd:
Can you run the attached program when you have a PPTP VPN connected, select all the lines in the output window, copy then paste into a text file and attach it to a reply here?

Doesn't do anything strange, just reports information regarding network devices: device names, status, etc - no secret information, (source included so anyone can check).

pilgrim:
File attached. I've resized the columns to fit the text, any columns that are missing were empty.

[attachmini=#][/attachmini]

4wd:
Thanks - looks like this is going to be a bit of fun, the PPTP not having a physical connection means I need another way to see if it's online, (possibly something as simple as count the number of IPs periodically).

Quick question, do you only ever have one PPTP VPN connected at a time?

EDIT: Worked out how - some things are so easy once you stop looking too hard  :-[


PPTPchek - Simple PPTP connection monitor (I'm starting to run out of names)

Nothing fancy, same command args as ConnStat above:

PPTPcheck.exe [delay]       - delay = optional delay before monitoring starts
eg. PPTPchek.exe 30

All it does is call rasdial.exe every 2 seconds, if the named connection no longer exists the program exits.


--- Code: AutoIt ---#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_Icon=netshell_190.ico#AutoIt3Wrapper_UseUpx=n#AutoIt3Wrapper_Res_Fileversion=0.3.0.20#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y#AutoIt3Wrapper_Res_Icon_Add=netshell_193.ico#AutoIt3Wrapper_Res_Icon_Add=netshell_191.ico#AutoIt3Wrapper_Res_Icon_Add=netshell_192.ico#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #comments-start PPTPchek- Displays an icon in the SysTray while the specified PPTP connection exists PPTPchek.exe [delay] where: [delay]       = Optional delay before monitoring starts (in seconds) eg.  PPTPchek.exe 30 Tray icon will  change colour at the end of the delay period, (if given or when rasdial.exe has finished), to indicate monitoring has begun. NIC status will be checked every 2000 milliseconds. PPTPchek can be terminated by causing the PPTP connection to disconnect, (eg. pull the cable), or choosing Exit from the icon context menu. If the icon is flashing between its normal icon and a red cross it indicates the program is PAUSED - use the context menu to unpause.#comments-end #include <Constants.au3>#include <StaticConstants.au3> Opt("TrayAutoPause", 0) TraySetState()                                                                   ; Show tray iconIf $CmdLine[0] > 1 Then        If Int($CmdLine[2]) > 0 Then                $j = 0                $i = TimerInit()                While $j < Int($CmdLine[2]) * 1000                          ; Loop until delay expired                        $j = TimerDiff($i)                        If ProcessExists("rasdial.exe") = 0 Then ExitLoop   ; If rasdial.exe process doesn't exist, exit the loop                        Sleep(1000)                WEnd        EndIfEndIfTraySetState(2)                                                                 ; Hides tray icon after delayTraySetIcon(@ScriptName, -5)                                         ; Change iconTraySetState(1)                                                                 ; Show tray icon, ie. monitoring starts While 1        If _GetState() = "" Then _Exit()        Sleep(2000)WEnd  Func _Exit()        ExitEndFunc  Func _GetState()        While ProcessExists("rasdial.exe")                Sleep(250)        WEnd        Local $foo = Run(@comspec & ' /c rasdial.exe', '.', @SW_HIDE, $STDOUT_CHILD)        If @error Then                MsgBox(48, "PPTPchek", "PPTPchek: Failed to run rasdial.exe")        EndIf        Local $output        $output = ''        While 1                $output &= StdoutRead($foo)            If @error <> 0 Then ExitLoop        WEnd        StdioClose($foo)        If StringInStr($output, "No connections") Then Return ""        Local $temp = StringSplit($output, @CRLF)        TraySetToolTip($temp[2])        Return $temp[2]EndFunc
UPDATE:

* Monitoring delay will be terminated as soon as the rasdial.exe process terminates.
* ToolTip now indicates connection name.
* Doesn't need a connection argument, (for running via Task Scheduler)
* Checks to see if rasdial.exe is running before executing it
* Interval changed to 2 seconds

pilgrim:
After many false starts, I think my memory is degrading, it works as advertised, thank you.
The icon is also reappearing in the same location if I stop and then restart the connection.
I have swapped the icons around in the exe, after running it for a while I decided the darker icon (193) looks better most of the time and the brighter one (190) catches my attention more when it first connects.
All I need to do now is sort the batch files and the shortcuts out for individual VPN's.

You have made using my computer a little bit easier and saved me countless hours of trying to sort this out myself, at the end of which I would probably have given up.
Before I leave this subject I have one further question if you don't mind:

All it does is call rasdial.exe every 5 seconds, if the named connection no longer exists the program exits.
--- End quote ---

I have been trying for a long time to find a way to put an argument into a batch file that states: 'if PPTP is (not) connected then........'.
Can your idea be used in that way and if so how would it read?

4wd:
Before I leave this subject I have one further question if you don't mind:

All it does is call rasdial.exe every 5 seconds, if the named connection no longer exists the program exits.
--- End quote ---

I have been trying for a long time to find a way to put an argument into a batch file that states: 'if PPTP is (not) connected then........'.
Can your idea be used in that way and if so how would it read?-pilgrim (May 03, 2013, 05:18 AM)
--- End quote ---

Off the top of my head, something along the lines of:


--- Code: Text ---rasdial.exe | find /i "no connections" >NULif errorlevel 1 goto running echo No PPTP connection goto alldone:running echo PPTP connection exists :alldone
ie.
Execute rasdial and pipe the output to FIND to search for "no connections", (case insensitive), if it doesn't exist the errorlevel will be 1 so we jump to the running label.

You have made using my computer a little bit easier and saved me countless hours of trying to sort this out myself, at the end of which I would probably have given up.
--- End quote ---

No problem, gives me something to do besides blast things in Borderlands 2  ;D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version