Script required to automatically connect to specific Wi-Fi network  

Page 3 of 8 FirstFirst 12345 ... LastLast

  1. Posts : 16,191
    Windows 10 Home x64 Version 22H2 Build 19045.3693
       #21

    W10 Tweaker said:
    How about, if my PC is sleeping, network connection is disconnected, am I not isolated until I reconnect?
    Michael,

    You have not been addressing the subject of disconnecting from the network, only connecting to it.

    Denis
      My Computer


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

    Try3 said:
    Michael,

    You have not addressed the subject of disconnecting from the network, only connecting to it.

    Denis

    I've been wondering about that.

    Even though, whenever it returns from sleep, my network connection is disconnected. How can I be certain it is disconnected and remains so while in sleep state without manually disconnecting after use or creating another script to automatically disconnect the network during sleep or hibernate.
      My Computer


  3. Posts : 7,600
    Windows 10 Home 20H2
       #23

    Use a script to check whether connection is available during sleep. However, is it possible to run a script during sleep?
      My Computer


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

    Matthew Wai said:
    Use a script to check whether connection is available during sleep. However, is it possible to run a script during sleep?

    I wonder if it would be wiser to just run a script to disconnect the network connection as it enters sleep, if that's even possible.


    How about using 'On Workstation lock' as a trigger in the task scheduler.
      My Computer


  5. Posts : 16,191
    Windows 10 Home x64 Version 22H2 Build 19045.3693
       #25

    W10 Tweaker said:
    I've been wondering about that.
    Even though, whenever it returns from sleep, my network connection is disconnected. How can I be certain it is disconnected and remains so while in sleep state without manually disconnecting after use or creating another script to automatically disconnect the network during sleep or hibernate.
    Michael,

    I looked at my internet connection [my phone's WiFi hotspot] after logging out and could see that it was still connected.
    I can use the same method to confirm that connections drop off when sleeping.


    You have used code to set things up to reconnect automatically when logging on.
    - When you resume from sleep, I think nothing happens since your TS task triggers are just for logon & 'On Workstation unlock' [not 'reconnect to user session'].
    - So you have done what you said you wanted to do i.e. I was wrong to say there was no difference between what you are doing and just letting it reconnect automatically in the normal way.
    - But it is sleeping rather than logging out that achieves this behaviour.
    - I do urge you to check your router to see how you might monitor connections & disconnections to confirm that it is all behaving as you think.

    Denis
      My Computer


  6. Posts : 7,600
    Windows 10 Home 20H2
       #26

    W10 Tweaker said:
    run a script to disconnect the network connection
    netsh wlan connect will start the connection.
    What is the command for stopping the connection?

    W10 Tweaker said:
    Now when I close the lid or sleep, upon opening the lid and unlocking the PC, it runs the script and logs into the Wi-Fi automatically.
    Am I right in thinking that my VBScript (in post #8) works, and your CMD/batch script is not needed?
      My Computer


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

    Matthew Wai said:
    netsh wlan connect will start the connection.
    What is the command for stopping the connection?
    netsh wlan disconnect

    Script required to automatically connect to specific Wi-Fi network-0306-netsh-wlan-disconnect.jpg



    Matthew Wai said:
    Am I right in thinking that my VBScript (in post #8) works, and your CMD/batch script is not needed?
    I'll have to check that. It worked fine in Powershell, so should be OK using the Task Scheduler.

    Thanks, I would much prefer using your single file than what I have now. I had no idea this would be such a PITA but I have been fiddling with it for awhile.
      My Computer


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

    Try3 said:
    Michael,

    I looked at my internet connection [my phone's WiFi hotspot] after logging out and could see that it was still connected.
    I can use the same method to confirm that connections drop off when sleeping.


    You have used code to set things up to reconnect automatically when logging on.
    - When you resume from sleep, I think nothing happens since your TS task triggers are just for logon & 'On Workstation unlock' [not 'reconnect to user session'].
    - So you have done what you said you wanted to do i.e. I was wrong to say there was no difference between what you are doing and just letting it reconnect automatically in the normal way.
    - But it is sleeping rather than logging out that achieves this behaviour.
    - I do urge you to check your router to see how you might monitor connections & disconnections to confirm that it is all behaving as you think.

    Denis

    Thanks Denis, that's excellent info. So just to clarify, you are stating that you observed the network connection disconnect when entering sleep?

    That was only an assumption on my part but confirmation would save an addition disconnect script.
      My Computer


  9. Posts : 16,191
    Windows 10 Home x64 Version 22H2 Build 19045.3693
       #29

    Michael,

    Yes, sleeping is disconnecting you. You do not need to change anything if that meets your needs.

    Denis
      My Computer


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

    Try3 said:
    Michael,

    Yes, sleeping is disconnecting you. You do not need to change anything if that meets your needs.

    Denis

    We were typing at the same time.

    Thanks for confirming the network disconnect during sleep.
      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 02:53.
Find Us




Windows 10 Forums