Script required to automatically connect to specific Wi-Fi network

Page 8 of 8 FirstFirst ... 678

  1. Posts : 1,807
    Windows 10 Pro 21H1 19043.1348
    Thread Starter
       #71

    W10 Tweaker said:
    OK, new vbs code set and I did include the last line for potential future diagnostics.

    I ran the task manually and it scored 10 successful network connects for 10 attempts. Bravo and thanks for your continued support.

    I'll start and maintain a new reliability summary in this post.



    2 successful auto-connect to Wi-Fi out of 4 attempts.

    The 2 previous attempts to connect after returning from sleep failed and produced an 'Error code: 1'.


    Script required to automatically connect to specific Wi-Fi network-0311-connect-error-1.jpg
    Last edited by W10 Tweaker; 12 Mar 2021 at 08:32.
      My Computer


  2. Posts : 1,746
    Windows 10 Pro x64 22H2
       #72

    Error code 1 if it's related to netsh.exe means:

    netsh command failed
    client disconnected
    I figured this out after googling from one screenshot HERE

    If so and unless I'm wrong capturing logs (and reasons for failure) can be done also with netsh:
    https://docs.microsoft.com/en-us/win...-manage-traces
      My Computer


  3. Posts : 7,607
    Windows 10 Home 20H2
       #73

    In "C:\Scripts\WLAN\Netsh.vbs", replace the original code with the following:
    Code:
    Set X=CreateObject("WScript.Shell"):Do:Return=X.Run _
    ("%WinDir%\System32\netsh.exe wlan connect ""[ssid]"" ""{profile name]"" ""Wi-Fi""",0,True)
    If Return = 0 then WScript.Quit 
    Attempts = Attempts + 1 : Loop until Attempts = 4
    X.Run"C:\Scripts\WLAN\Testing.cmd":MsgBox "Error code: "&Return

    Copy the following code into "C:\Scripts\WLAN\Testing.cmd", which will be run only if VBScript has failed to start the connection.
    Code:
    @echo off
    Netsh WLAN connect "[ssid]" "{profile name]" "Wi-Fi"
    Echo The errorlevel is %errorlevel%
    Netsh WLAN show interfaces
    Netsh WLAN show networks
    Netsh WLAN show drivers
    Netsh WLAN show profiles
    pause>Nul
    Hopefully, it will show the culprit.


    zebal said:
    I figured this out after googling from one screenshot HERE
    By googling, I found the following example:
    Code:
    Mon Nov 18 17:15:25 2013 ERROR: netsh command failed: returned error code 1
    Mon Nov 18 17:15:29 2013 MANAGEMENT: Client disconnected
    Mon Nov 18 17:15:29 2013 NETSH: command failed
    Source: [Closed] ERROR: netsh command failed: returned error code 1 - OpenVPN Support Forum
    Last edited by Matthew Wai; 12 Mar 2021 at 00:37.
      My Computer


  4. Posts : 1,807
    Windows 10 Pro 21H1 19043.1348
    Thread Starter
       #74

    zebal said:
    Error code 1 if it's related to netsh.exe means:
    I figured this out after googling from one screenshot HERE

    If so and unless I'm wrong capturing logs (and reasons for failure) can be done also with netsh:
    https://docs.microsoft.com/en-us/win...-manage-traces
    Thanks for the info zebal and contributing.



    Matthew Wai said:
    In "C:\Scripts\WLAN\Netsh.vbs", replace the original code with the following:
    Code:
    Set X=CreateObject("WScript.Shell"):Do:Return=X.Run _
    ("%WinDir%\System32\netsh.exe wlan connect ""[ssid]"" ""{profile name]"" ""Wi-Fi""",0,True)
    If Return = 0 then WScript.Quit 
    Attempts = Attempts + 1 : Loop until Attempts = 4
    X.Run"C:\Scripts\WLAN\Testing.cmd":MsgBox "Error code: "&Return

    Copy the following code into "C:\Scripts\WLAN\Testing.cmd", which will be run only if VBScript has failed to start the connection.
    Code:
    @echo off
    Netsh WLAN connect "[ssid]" "{profile name]" "Wi-Fi"
    Echo The errorlevel is %errorlevel%
    Netsh WLAN show interfaces
    Netsh WLAN show networks
    Netsh WLAN show drivers
    Netsh WLAN show profiles
    pause>Nul
    Hopefully, it will show the culprit.



    By googling, I found the following example:
    Code:
    Mon Nov 18 17:15:25 2013 ERROR: netsh command failed: returned error code 1
    Mon Nov 18 17:15:29 2013 MANAGEMENT: Client disconnected
    Mon Nov 18 17:15:29 2013 NETSH: command failed
    Source: [Closed] ERROR: netsh command failed: returned error code 1 - OpenVPN Support Forum

    Excellent! Thanks again for your continued perseverance.

    Hopefully, this will produce a clue as to where the failure is happening.


    I've updated the Netsh.vbs file and added the 'Testing.cmd' file.




    2 successful auto-connect to Wi-Fi out of 2 attempts.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 18:43.
Find Us




Windows 10 Forums