Sign in to follow this  
Followers 0
SDG

How can I convert this batch file to autoIt script?

6 posts in this topic

+-----------------------------------------------------------------------
Batch File to open a ssh tunnel to remote host
-----------------------------------------------------------------------+
start C:\putty.exe -N -L 127.0.0.1:443:10.0.0.29:443 -l Admin -pw password myfirewall.net
ping localhost -n 3 
start https://127.0.0.1

Dear all,

The batch file above is meant to open a ssh tunnel to the remote host 10.0.0.29 via my firewall send three ping packets then launch the default browser to local host which will open the remote host.

I want Auto-It script to read the username and password form an input and then launch the browser to the remote host as ssh tunnel.

The Idea is to have many Buttons to launch deterrent tunnels.

Any Ideas and solution are warmly welcomed.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <process.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("IPconnect", 200, 150, 192, 100)
$Input1 = GUICtrlCreateInput("user", 88, 8, 105, 21)
$Input2 = GUICtrlCreateInput("password", 88, 40, 105, 21)
$Button1 = GUICtrlCreateButton("Tunnel1", 24, 96, 113, 25)
$Group1 = GUICtrlCreateGroup("Tunnels", 16, 60, 180, 70)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Username", 24, 8, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Password", 24, 40, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Many Thanks In Advance.

 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hi John,

 

 

I don't know what putty is but a start might be something like...

Run("C:\putty.exe -N -L 127.0.0.1:443:10.0.0.29:443 -l Admin -pw password myfirewall.net")
Ping("localhost")
ShellExecute("https://127.0.0.1")

 

Many thanks for the fast reply. you script is doing well.

however what I want is to read the username and password from the $Input1$Input2. so that other user can log on with their credentials instead of the the user Admin and the password Password.

Run("C:\putty.exe -N -L 127.0.0.1:443:10.0.0.29:443 -l GUICtrlRead($Input1) -pw GUICtrlRead($Input2) myfirewall.net")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("IPconnect", 200, 150, 192, 100)
$Input1 = GUICtrlCreateInput("user", 88, 8, 105, 21)
$Input2 = GUICtrlCreateInput("password", 88, 40, 105, 21)
$Button1 = GUICtrlCreateButton("Tunnel1", 24, 96, 113, 25)
$Group1 = GUICtrlCreateGroup("Tunnels", 16, 60, 180, 70)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label1 = GUICtrlCreateLabel("Username", 24, 8, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Password", 24, 40, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Edited by SDG

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

Try..

Run("C:\putty.exe -N -L 127.0.0.1:443:10.0.0.29:443 -l " & GUICtrlRead($Input1) & " -pw " & GUICtrlRead($Input2) & " myfirewall.net")

Thanks a lot John, yes this is the best solution of my question

Cheers.

Edited by SDG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0