Kill Applications on Sleep Timer in Windows / by David Cheeseman

One of the things I've wanted to do with windows is create a quick way to kill a task on a timer without screwing with scheduled tasks.  That way I could put on a video playlist to get to sleep and still use my computer to wake up in the morning (i.e. not using the shutdown command; my computer's encrypted and a force restart would disable my computer's alarm clock).  Either way, I wrote the following batch-script which you can thrown in the C:\Windows folder to get this functionality without any additional software.  The file is linked here for download, but the code is listed below:

@echo sleep_kill.bat [seconds] [task]

@rem Ping a fake address and have a n second timeout specified by
@rem    the user.
@rem If this fails, try chainging it to a different local-space ip
@rem    adress that doesn't exist on your network such as if
@rem    you have a 192.168.1.x address space.
@ping -n 1 -w %1000 > nul

@rem Once time has ellapsed, kill the process specified.  ex: vlc.exe
@taskkill /F /IM %2