Tuesday, January 20, 2015

windows 7 - Using plink.exe or similar in a scheduled task (to be run continuously)

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:


Never turn off hard drive
Don't allow computer to turn off NIC

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...