3
I've been trying to get plink.exe
(from the maker of PuTTY) to establish a local SOCKS proxy to a remote site, as well as some tunnels.
The action is simply to start plink.exe
with the right parameters. No questions there.
The conditions tie the start to an available network connection, which I thought to be sensible.
Then I also set it to:
- Allow task to be run on demand
- Run task as soon as possible after a scheduled start is missed
- If the task fails, restart every: [1 minute]
- If the running task does not end when requested, force it to stop
Now all of this works perfectly fine at system start. However, when I put the machine to sleep and wake it up again, this fails.
In fact right after waking up, the plink.exe
console window is still visible, but disappears (likely because the SSH session from before the sleep long timed out). However, the status of the task is then still listed as Running although it's clearly gone (i.e. if I were to use CreateProcess
, I'd be notified of the process having gone away).
The status means I have to explicitly End it and then explicitly Run it again.
Does anybody know a method by which I can essentially teach the scheduled tasks that it should restart the job when the process goes away? I have no idea what the exact metric is, but clearly the Running status I am observing is bogus.
The idea is to restart plink.exe
(thus reestablishing the SOCKS proxy) whenever it goes down. Be that right after the startup and a failed connection attempt or be that after waking the machine up from sleep.
NB: I am looking for a solution that can work on both Windows 7 and Windows 10.
As per the suggestions in the comments, the following two settings have been changed:
Is your Network Adapter set to turn off to save power when it sleeps? open
devmgmt.msc
and double click on your network adapter and go to power management and make sure to uncheck Allow the computer to turn off the device to saver power if it is not greyed out. – NetworkKingPin – 2016-03-29T08:13:40.687@NetworkKingPin: I just turned it off, it was not greyed out. However, after putting the machine to sleep and waking it again, the problem is exactly the same as before. – 0xC0000022L – 2016-03-29T08:29:48.390
I wonder if its possible that the Reason the Program stops is when its asleep it stops the HDD from moving. try this In the Power Options box that opens, click the + sign next to the Hard Disk option. Here you will see the required settings under Turn off hard disk after heading. Change the value to 0. – NetworkKingPin – 2016-03-29T08:34:19.503
@NetworkKingPin: I'm not sure, but you may have misunderstood the question. Being a driver writer, I can tell you that oftentimes a user mode program won't have the slightest clue about certain resources being unavailable during sleep. Network is a special case, since the uplink takes some time to renegotiate. That said: I'll change the value and report back. – 0xC0000022L – 2016-03-29T08:53:24.873
@NetworkKingPin: no change after adjusting that setting, either. Just tested it. – 0xC0000022L – 2016-03-29T09:07:00.587