TL;DR at the bottom!
I have an unreliable internet connection due to 2 reasons on my Win 10 laptop, which is connected wirelessly to my router, which is connected by wire to my modem.
Reason 1, something that isn't Win 10's fault: My modem often fritzes out (IDK if it's the modem itself, the ISP, or what, but yeah), whereby it kinda just restarts. When this happens, the internet on my laptop (obviously) goes out too, but it then doesn't reconnect when the modem comes back on. The only way it'll do so is if I disable, then enable, my wireless adapter from the Network Connections window.
Reason 2, something that is Win 10's fault: My laptop sometimes gets kicked off the Wi-Fi network. This itself might be caused by something other than Win 10, like my NIC, or my router. What annoys me is when Win 10 then doesn't automatically reconnect to the network even though it's supposed to. When I click on the "Connect" button in the Wi-Fi menu myself, it works fine.
I decided to make a *.bat file that would detect whenever either of the scenarios occurred, and then fix the problem. With a little bit of research on the internet, I managed to put together the following script:
@echo off :LOOP ping 184.108.40.206 IF ERRORLEVEL 1 goto RESTART IF ERRORLEVEL 0 goto LOOP :RESTART netsh interface set interface "<wireless adapter>" disabled netsh interface set interface "<wireless adapter>" enabled netsh wlan connect name="<ssid>" interface="<wireless adapter>" timeout /t 15 goto LOOP
This works great (when it's Run as Administrator), but now the problem is that I want the cmd window to not remain open (on screen, and in the taskbar) while the process runs; I want it to run in the tray instead, so I can still easily exit it if I need to, without having to go to the Task Manager. I know I can schedule the script in the Task Scheduler to start minimized on start-up, but won't that just hide the window from taskbar?
How do I make a *.bat file run in the tray / by the clock where I can easily right-click it and stop/exit? Is compiling an executable the only way to achieve this?