Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect / Disconnect WiFi and Hibernate
#1
Note: This post has been edited to place the updated code here.

Network Connect Routine (Does not trigger a Windows UAC response).
Code: (Select All)
Width 36, 3
Color 15, 1: Cls
_Font 16
Locate 2, 2
Print "Connecting to your network...";
Shell _DontWait _Hide "netsh wlan connect name=YOUR WIFI NAME HERE"
_Delay 2
System

Create the exe file, right click it, and send it to your desktop.

Network Disconnect (Triggers a UAC response, but see how to avoid this by pigging backing onto Task Scheduler).
Code: (Select All)
Width 36, 3
Color 15, 1: Cls
_Font 16
Locate 2, 2
Print "Disconnecting from your network...";
Shell _DontWait _Hide "netsh wlan disconnect"
_Delay 2
System

To avoid the UAC, do this...

1) Open Windows Task Scheduler
2) Add a new folder. I named mine: My Network Disconnect
3) Click on the new folder and select to add a 'new task'. I named my new task: Network Disconnect
4) Make sure you check the box: Run with highest privileges
5) In the trigger tab, select to run on login.
6) In the actions tab, set the path and name of your disconnect program. Mine is: c:\my-exe-files\network disconnect.exe
7) Click OK to save the new task.

Next I used File Explorer to view my c:\my-exe-files\network disconnect.exe. I did a right click, selected 'Properties' and checked the box: Run as Administrator

Finally I tested the new task by clicking the "Run" command in the right panel of the Task Scheduler. It disconnected my internet connection, woohoo!

I made a desktop shortcut of Task Scheduler. I right clicked the shortcut and selected Properties.

I changed the Target to: C:\Windows\System32\schtasks.exe /RUN /TN "\My Network Disconnect\Network Disconnect"

The Start in: C:\Windows\System32

I changed the window to run minimized and saved my changes.

When I Double clicked the shortcut icon, woohoo again, it correctly communicated with Task Scheduler and shut off my wifi connection without getting a UAC prompt.

Hibernate PC (No UAC trigger).
Code: (Select All)
Width 36, 3
Color 15, 1: Cls
_Font 16
Locate 2, 2
Print "Hibernating..."
a$ = "shutdown /h"
Shell _DontWait _Hide a$
System

+1 to Steve and Spriggs for getting involved in the discussion. I had to work it out myself this time, but the support is very much appreciated.

Pete

------------------------------------------------------------

ORIGINAL POST TO EXPLAIN DISCUSSION THAT FOLLOWS

I created a desktop icon from the exe file. It works on my Windows 10. What I would like is to get around the UAC prompt it triggers. (User Account Control). I would have to turn UAC off.

I did try to go around it by making a folder in Task Scheduler. So, if I run it from Task Scheduler, directly, it works without a UAC warning, but when I make a desktop shortcut to trigger Task Scheduler to run it, guess what? If you said UAC asks me to verify I want to let Task Scheduler change my computer, you are correct! Anyway, the article I read for doing this Task Scheduler was 11 years old, so my guess is it worked back then, but not today.

If anyone knows another way around it, I'd love to read your post; otherwise, I'll keep on searching and let you guys know if I find anything.
------------------------------------------------------------
Shoot first and shoot people who ask questions, later.
Reply


Messages In This Thread
Connect / Disconnect WiFi and Hibernate - by Pete - 08-20-2024, 02:57 AM
RE: Disconnect WiFi - by SMcNeill - 08-20-2024, 03:38 AM
RE: Disconnect WiFi - by Pete - 08-20-2024, 04:58 AM
RE: Disconnect WiFi - by SpriggsySpriggs - 08-20-2024, 11:58 AM
RE: Disconnect WiFi - by Pete - 08-20-2024, 04:08 PM
RE: Disconnect WiFi - by SpriggsySpriggs - 08-20-2024, 05:30 PM
RE: Disconnect WiFi - by Pete - 08-21-2024, 12:05 AM
RE: Disconnect WiFi - by SMcNeill - 08-21-2024, 03:53 AM
RE: Disconnect WiFi - by Pete - 08-21-2024, 04:53 AM



Users browsing this thread: 3 Guest(s)