5

I was wondering if it's possible to disconnect my desktop PC from the internet entirely when starting a screensaver? I would also like to reconnect to the previously selected network (I'm using a wi-fi card at the moment) when the screensaver shuts off. Currently I'm running a batch file when the screensaver starts so that I can start backups, and then the batch file starts a screensaver I made, so if I need to I can call another batch file on quit. Another option is using the .NET API to do it, but I've been unable to find any resources on interfacing with Windows functionality with that. I'm running Windows 8 Pro.

Thanks!

1
  • How are you running the batch file? Would disabling the network card work for you?
    – and31415
    Jul 28, 2014 at 7:41

1 Answer 1

1

Yes this is possible with a little bit of scripting.

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Intel(R) 82567LM-2 Gigabit Network Connection*"}
$ssrunning = (Get-Process -name notepad -ErrorAction SilentlyContinue)
if ($ssrunning){$adaptor.Disable()}
else{$adaptor.Enable()}

Its actually easier in Windows 8.1 & 2012. There are Powershell 4 cmdlets called enable-netadpter and disable-netadapter which would simplify the process... but this is more generic and should work on most machines.

From a Powershell prompt run Get-WmiObject -Class Win32_NetworkAdapter to list out your network adapter names. In the script, replace Intel(R) 82567LM-2 Gigabit Network Connection with the name of your adapter.

Also, you will need to know the process name of your screeensaver, if it was mystify.scr, I believe the process would just be called mystify. Replace notepad in the script with the name of the process.

Just run this Powershell script elevated (it has to be to enable/disable the adapters), perhaps as a Windows scheduled task and you are good to go.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .