How Can I Remotely Restart a Program on a Windows 7 Computer?
February 25, 2013 12:10 PM   Subscribe

Any ideas on how I could have one PC listen for a specially formatted packet/etc., and when it detects that packet/etc. shut down a program?

I have a Windows 7 computer which I am using to serve media files to a media player connected to my television. I've tried many media server programs, and the one that works best for me is Twonky. However, about once a day (at different times of the day), Twonky stops responding. When that happens, I have to go to the other room and shut down the "Twonkyserver.exe" program. When I shut it down, it automatically restarts, and Twonky works fine.

However, 1) it's a bit of a pain in the butt to go to the other (non-heated) room to do this, and 2) when it happens and I'm not at home, my wife and kids can't watch anything.

I've tried using Windows 7 remote access to access the computer and manually restart the program, but it takes waaaaay too long to do almost every day.

Ideally, I'd like to be able to configure the main box to, say, listen to a specific port or something, and then from the living room PC, double-click on something (a batch file, etc.) which would send a command/specially formed packet/access a specially designated port/etc. to the main PC. The main PC, detecting this special traffic/packet/etc. would in turn run a batch file, etc. which just shuts down twonkyserver.exe (which would then automatically restart). So I (or my wife, or eventually my kids) would know "when the TV stops working, double-click this icon on the living room desktop, and wait 10 seconds". Any ideas?
posted by Bugbread to Computers & Internet (11 answers total)
 
Best answer: I think you can probably use Taskkill to kill the process remotely. Not exactly sure how you'd start the process again though.
posted by pipeski at 12:19 PM on February 25, 2013 [1 favorite]


Oh, this might do it: Rexec. You'd probably want to introduce a delay in your batch file between the two commands though...
posted by pipeski at 12:23 PM on February 25, 2013


Is the main PC always on? Maybe create a scheduled task to kill and restart Twonkyserver.exe overnight? I'd work on figuring out exactly why the server needs a restart in the first place.
posted by dobi at 12:24 PM on February 25, 2013


Response by poster: The main PC is always on, but Twonky doesn't stop responding at specific times, it seems more random, so a restart at night wouldn't solve the problem. I'm looking into seeing what's wrong with it, but that may take pretty much forever, so until I can solve the root problem (if that's possible), I'm looking for a daily solution.

Pipeski: thanks for the recommendations. Rexec isn't offered in Windows 7, but taskkill seems to fit the bill perfectly. Unfortunately, I can't get it to work, but I'll keep plugging at it.

If anyone else has any solutions, they're greatly appreciated.
posted by Bugbread at 12:44 PM on February 25, 2013


You could always set up something like TeamViewer remote desktop software. Then the process would boil down to: Launch TeamViewer from living room PC -> Connect to main PC -> Double click on batch script to restart server.
posted by dobi at 12:48 PM on February 25, 2013


Rexec would probably do it, though I think it requires installing the rexec service on the remote machine. If you want to avoid that, consider psexec.

You say twonky stops responding periodically: if that means it stops responding to network connections, you could write a simple scheduled task on your main machine to attempt a network connection to your server every five minutes, via whatever port it uses, using portqry.exe. And if it fails (test via errorlevel), call taskkill against twonkeyserver.exe remotely.

Though I agree with dobi that every minute you spend on this is a minute you could be spending trying to troubleshoot twonky. :) But, sometimes you just need a workaround...
posted by molybdenum at 1:09 PM on February 25, 2013


Use Event ghost with the web server plugin. Then you can create a url that does exactly what you are asking.
posted by jmsta at 1:10 PM on February 25, 2013


I used to use Servers Alive on some Windows servers I ran and when it detected specific errors, I could have it stop and start services. You could probably set it up to watch a twitter feed or some other easy thing and have it kill the service.
posted by advicepig at 2:16 PM on February 25, 2013


Response by poster: Ok, I finally got taskkill working (had to do some registry tweaks to get ADMIN$ to appear), and it works beautifully, simply, and minimally. Thanks, pipeski, and everyone else, for your help.
posted by Bugbread at 2:58 PM on February 25, 2013


Best answer: If you aren't already, add /F to taskkill so it forces the process to die if it's uncooperative.
posted by MonsieurBon at 3:54 PM on February 25, 2013


Response by poster: Thanks, MonsieurBon, I just added that to my batchfile.
posted by Bugbread at 7:26 PM on February 25, 2013


« Older Website for good focused daily workout routines   |   Minor car accident - question about insurance... Newer »
This thread is closed to new comments.