Nareshm

Connect/Disconnect DialUp Internet Without CMD

25 posts in this topic

#1 ·  Posted

its possible to Connect/Disconnect my DialUp internet connection without using CMD ?
If yes, How to it ?

Share this post


Link to post
Share on other sites



#3 ·  Posted

?? maybe this:

ShellExecute("rasdial", "/disconnect")

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#4 ·  Posted

29 minutes ago, Jos said:

Why without using CMD? 

Jos

CMD takes long time to connect/Disconnect

Share this post


Link to post
Share on other sites

#5 ·  Posted

What does that mean?   CMD doesn't take much more time that milliseconds, so what exactly are you running that takes times?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted

2 minutes ago, Jos said:

What does that mean?   CMD doesn't take much more time that milliseconds, so what exactly are you running that takes times?

Jos

@Jos
Can i post my question/answer in hindi beacause i don't understand english very well

Share this post


Link to post
Share on other sites

#7 ·  Posted

No as that will not mean  anything to me and we want  to keep this forum English. I am Dutch so English isn't my native language either.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted

1 minute ago, Jos said:

No as that will not mean  anything to me and we want  to keep this forum English. I am Dutch so English isn't my native language either.

Jos

Okk @Jos sir
i am create script for disconnect my internet then suddenly connect my internet Using Rasdial command, but when disconnect is proccesing connect command run but not connecting beacoz disconnect command already in progress then manualy not connecting my internet until i restart my computer

Share this post


Link to post
Share on other sites

#10 ·  Posted

7 minutes ago, Jos said:

Which script ?  Post it!

Jos

@Jos
Please wait i am busy in my onther work
sorry for that

Share this post


Link to post
Share on other sites

#11 ·  Posted

@Jos
Run("rasdial /disconnect")
Run("rasdial Internet")

Share this post


Link to post
Share on other sites

#12 ·  Posted

Run("rasdial /disconnect", @ScriptDir, @SW_HIDE)
Run("rasdial Internet", @ScriptDir, @SW_HIDE)

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#13 ·  Posted

2 minutes ago, TheDcoder said:
Run("rasdial /disconnect", @ScriptDir, @SW_HIDE)
Run("rasdial Internet", @ScriptDir, @SW_HIDE)

@TheDcoder
after disconnect it was not connecting
When connected then run script only disconnect
when disconnected then run script only connect

 

Share this post


Link to post
Share on other sites

#14 ·  Posted

I don't know how rasdial works, I have only showed you the example to hide the CMD window :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#15 ·  Posted

1 minute ago, TheDcoder said:

I don't know how rasdial works, I have only showed you the example to hide the CMD window :)

Okk Thanks

Share this post


Link to post
Share on other sites

#16 ·  Posted

:'(

If _IsInternetConnected() Then 
    Run("rasdial /disconnect", "", @SW_HIDE) ; When connected then disconnect
Else
    RunWait("rasdial Internet", "", @SW_HIDE) ; when disconnected then connect
EndIf


Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then Return SetError(1, 0, 0)
    Return ($aReturn[0] = 0)
EndFunc   ;==>_IsInternetConnected

 


Regards,
 

Share this post


Link to post
Share on other sites

#17 ·  Posted

2 minutes ago, VIP said:

:'(

If _IsInternetConnected() Then 
    Run("rasdial /disconnect", "", @SW_HIDE) ; When connected then disconnect
Else
    RunWait("rasdial Internet", "", @SW_HIDE) ; when disconnected then connect
EndIf


Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then Return SetError(1, 0, 0)
    Return ($aReturn[0] = 0)
EndFunc   ;==>_IsInternetConnected

 

Thanks @VIP
But its Working like

Run("rasdial /disconnect", @ScriptDir, @SW_HIDE)
Run("rasdial Internet", @ScriptDir, @SW_HIDE)

I Need Script for
Disconnect internet for 1 second

Explain : Connect immediately after disconnecting the internet
If not connected then only connect

Share this post


Link to post
Share on other sites

#18 ·  Posted

??? insert a pause between disconnection  & reconnection ?

Run("rasdial /disconnect", @ScriptDir, @SW_HIDE)
Sleep(5000) ; pause 5 seconds
Run("rasdial Internet", @ScriptDir, @SW_HIDE)

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#19 ·  Posted

It's beyond my reach!
If you want to disconnect in just 1 second, you can quickly remove the dial-up modem plugged in to your computer!

This script will help keep you connected:

RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
Sleep(1000)
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again

Global $iError = 0, $iMaxErrorToRestartConnect = 10

While 1
    If Not _IsInternetConnected() Then
        $iError += 1
        RunWait("rasdial Internet", "", @SW_HIDE)
        If $iError > $iMaxErrorToRestartConnect Then RunWait("rasdial /disconnect", "", @SW_HIDE)
    EndIf
    Sleep(1000)
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then Return SetError(1, 0, 0)
    Return ($aReturn[0] = 0)
EndFunc   ;==>_IsInternetConnected

 


Regards,
 

Share this post


Link to post
Share on other sites

#20 ·  Posted

Forgot restart error:

RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
Sleep(1000)
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again

Global $iError = 0, $iMaxErrorToRestartConnect = 10

While 1
    If Not _IsInternetConnected() Then
        $iError += 1
        RunWait("rasdial Internet", "", @SW_HIDE)
        If $iError > $iMaxErrorToRestartConnect Then
            RunWait("rasdial /disconnect", "", @SW_HIDE)
            $iError = 0
            Sleep(5000)
        EndIf
    EndIf
    Sleep(1000)
WEnd

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then Return SetError(1, 0, 0)
    Return ($aReturn[0] = 0)
EndFunc   ;==>_IsInternetConnected

 


Regards,
 

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

  • Similar Content

    • Jefrey
      By Jefrey
      Hi!
      If you liked my TCPServer UDF, you'll also like this one.
      Following the same principles, this TCPClient UDF helps you on handling multiple connections to different servers, and set actions depending on two events: OnReceive and OnDisconnect.
      It is also multi server (you can connect to many servers at once) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create a TCP application and don't want to deal with the TCP* functions. Also, it runs on background just firing events, it won't pause your script while waiting/receiving data, so you can do anything else (close and open connections, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired
      It is also very easy to use. See this examples:
      Example #1: Connecting to a basic server
      By running this (as soon as you open a basic server with Netcat) you will receive a message box telling you when the server closes the connection (the socket ID and his IP address are passed as parameter to your callback function) and also when the server sends something over the TCP socket (the data sent is passed as parameter).
      #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv -l -p 8081 #ce #include "TCPClient.au3" ; First we set the callback functions for the two events (none of them is mandatory) _TCPClient_OnDisconnect("disconnect") _TCPClient_OnReceive("received") ; And a parameter _TCPClient_DebugMode(True) ; Finally we connect to the server at port 8081 at any interface _TCPClient_Connect('127.0.0.1', 8081) Func disconnect($iSocket, $sIP) MsgBox(0, "Server disconnected", "Server " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPClient_Send($iSocket, "You wrote: " & $sData) _TCPClient_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEnd Example #2: Requesting a page from a HTTP server
      In this example, we run this code and it will get the response from a HTTP server. Of course, as we are requesting google.com index, it may just show a redirect page to a local (with country top-level domain) Google page or with some stuff on the URL.
      #include "TCPClient.au3" _TCPClient_OnReceive("received") _TCPClient_DebugMode(True) $iSocket = _TCPClient_Connect(TCPNameToIP('google.com'), 80) If @error Then Exit _TCPClient_Send($iSocket, "GET / HTTP/1.0" & @CRLF & @CRLF) Func received($iSocket, $sIP, $sData, $sParam) MsgBox(0, "Data received", $sData) _TCPClient_Disconnect($iSocket) EndFunc ;==>received While 1 Sleep(100) WEnd Example #3: Command prompt bound to the socket after password requesting
      By running this example, we will be asked for a password, which is 123456 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example).
      #include "TCPClient.au3" #cs To test this example, execute a netcat server, running this commands: nc -vv -l -p 31337 #ce Global $Password = "123456" _TCPClient_OnReceive("receive") _TCPClient_OnDisconnect("disconnect") _TCPClient_DebugMode() Func receive($iSocket, $sIP, $sData, $mPar) If $mPar = "login" Then If $sData = $Password Then ; right password, let's change the parameter _TCPClient_SetParam($iSocket, "logged") ; and now bind _TCPClient_BindAppToSocket($iSocket, "cmd.exe") Else _TCPClient_Send($iSocket, "Wrong password. Try again: ") EndIf Else If $sData = "exit" Then ; unbinds _TCPClient_UnBindAppToSocket($iSocket) ; says bye _TCPClient_Send($iSocket, "See you") ; closes connection _TCPClient_Disconnect($iSocket) Else ; sends command directly to the process _TCPClient_SendToBound($iSocket, $sData) EndIf EndIf EndFunc Func disconnect($iSocket, $sIP) MsgBox(0, $iSocket, $sIP) EndFunc $iSocket = _TCPClient_Connect('127.0.0.1', '31337') If @error Then MsgBox(0, "", "could not connect. Error: " & @error) Exit EndIf ; Sets parameter to login, so we know what the server is doing _TCPClient_SetParam($iSocket, "login") _TCPClient_Send($iSocket, "Please enter password: ") While True Sleep(100) WEnd The limit is your imagination? Well, maybe.
      Functions list:
      _TCPClient_Connect($sSvr, $iPort)
      _TCPClient_Disconnect($iSocket)
      _TCPClient_SetParam($iSocket, $sPar)
      _TCPClient_Send($iSocket, $sData)
      _TCPClient_Broadcast($sData [, $iExceptSocket = 0 ])
      _TCPClient_ListConnections()
      _TCPClient_BindAppToSocket($iSocket, $sCommand [, $sWorkingDir = @WorkingDir ])
      _TCPClient_SendToBound($iSocket, $sData)
      _TCPClient_UnBindAppToSocket($iSocket)
      _TCPClient_OnReceive($sCallback)
      _TCPClient_OnDisconnect($sCallback)
      _TCPClient_DebugMode([ $bMOde = "toggle" ])
      _TCPClient_AutoTrim([ $bMode = "toggle" ])
      _TCPClient_SocketToConnID($iSocket)
      _TCPClient_ConnIDToSocket($iConn)
      _TCPClient_SocketToIP($iSocket) Help file and more examples included!
      Latest version: 1.0.0
      Download: https://www.autoitscript.com/forum/files/file/377-tcpclient-udf/
      Changelog
      1.0.0 - First release - 03/12/2015 If you can't open the help file, please uncompress it, go to properties and click Unlock.
      Fork me on Github: http://github.com/jesobreira/tcpclient-udf 
    • Jefrey
      By Jefrey
      Events-based UDF to help on handling one or more TCP connections
    • zxtnt09
      By zxtnt09
      Hi,
      How can i use a external function in TCPSend / TCPRecv ,
      It's meant : 
      TCPSend ( $main, function1 ) func function1 () msgbox (0,0,0) endfunc Q : Why i need to use that ? 
      A : I need when a connection was true ( connected ) , server could send some functions and client receive that,
      Me => <= You
      Thanks
       
       
    • Reinhardt1julian
      By Reinhardt1julian
      I have two seperate windows (GUIs). Now i want to link them, that they both get minimized when you minimize the "main" one and get maximized when you maximize one of them. The perfect way would be that only the "main" window has a thing down on the task bar (i don't know the exact word the thing next to the windows startmenu where all the running programs are displayed. It has the clock)