Windows Task Scheduler, Windows Media Player. Starting and Stopping
December 24, 2020 11:54 AM   Subscribe

For reasons, I need to play a specific playlist at a specific time every day. When that playlist ends, it leaves WMP open and the next time the specific time of day comes around, it doesn't play because WMP is still open. How can I get WMP to close? Assume that I'm using Windows Task Scheduler and Windows Media Player for good reasons and that unless there's an incredibly simple solution that doesn't involve internet access and won't make me snarl a lot, I'd like to stick with the task scheduler and media player.

The computer is not connected to the internet and cannot be connected to the internet from where it is located.

The music is being played through a stereo system.

I want the playlist to start at the beginning of a track and end at the end of a track so I don't want it to just play on repeat and turn the stereo off and on using a timer.
I'd like to not have to mess with the computer on a daily basis. Because that would add a 20 min x2 commute to my day seven days a week including Xmas and New Years.

Theoretically I should be able to use the task scheduler to run something that turns off WMP in the middle of the night so it is ready to go in the morning.

I'm not a person who knows how to code this and I'm uncomfortable just googling this because I wouldn't know a trustworthy source/code from a hole in the ground.

Help. Please. Thank you.

Also, if you're ever interested in designing an app that plays music at a specific time and for a specific duration and doesn't cut songs off in the middle and will work on a smartphone, you should consider it. Because other than expensive systems for restaurants and stores, it doesn't exist and from my perspective of gross ignorance it doesn't seem like it would be horribly difficult to create.

And no, the music playing alarm clocks don't seem to do this and IFTTT doesn't seem to have the right pieces to do it either.
posted by sciencegeek to Computers & Internet (9 answers total) 3 users marked this as a favorite
 
Best answer: Brute force solution: You can use Task Scheduler to schedule a regular reboot of the system. Be sure to disable startup and shutdown sounds, if you haven't already, so that your stereo system doesn't blare them at midnight or whatnot. Also, test it while you're watching to ensure that there's nothing running that would hold up a reboot.

Schedule the reboot soon after the playlist ends, to give maximum opportunity for someone to catch any reboot-related problems before the next playout, but time enough for adding to the playlist if that's a likely event.

Second possibility, which I'm less sure about and can't test right now: create a batch file (a text file saved with .bat as the extension) that says the following:

taskkill /im wmplayer.exe /t /f

Save it someplace where nobody will delete it accidentally (so, not the desktop), and schedule that to run after the playlist is well over. That command should force-quit the Windows Media Player. Try this command out manually to see if it works, first, before you schedule it.
posted by Sunburnt at 12:40 PM on December 24, 2020 [1 favorite]


It's a bit of a kludge, but this might be the simplest way to do it. It involves one batch file.

Open a new blank document in Notepad and copy in the following text:
taskkill /f /im wmplayer.exe
This means:
  • taskkill - the command to end a running process
  • /f - force. Don't ask the user to confirm ending the process with a yes/no prompt on the command line.
  • /im - specify the process by image name (as opposed to process id number)
  • wmplayer.exe - the image name of Windows Media Player
Name that text file something like "WMP-end.bat" and save it somewhere appropriate. You can test it out by starting up WMP, then double-clicking that file. If WMP closes, that should be working.

After that, you can set up Task Scheduler to run that batch file at an appropriate time. If you haven't done this with batch files before, these look like suitable directions in Windows 7 but Windows 10 should be identical.

On preview, what Sunburnt said.
posted by figurant at 12:43 PM on December 24, 2020 [3 favorites]


Response by poster: I'm going to try the batch file thing.

Reboot doesn't work because of login afterward. I've had weird issues with getting things to work when it requires login.
posted by sciencegeek at 12:45 PM on December 24, 2020


You can do this in one script with

wmplayer.exe whatever.mp3
:: 600 second pause while it plays, adjust this time
Timeout 600
taskkill /im wmplayer.exe /t /f
posted by Lanark at 1:07 PM on December 24, 2020 [2 favorites]


If reboot turns out to be the necessary option, you can set Win10 to auto-login. This isn't something I'd recommend in most cases, but a non-networked Win10 box built to play music is a pretty low-stakes, low-value target for hooliganism.

By the way, the /t switch on taskkill will kill child processes. I don't think WMPlayer spawns any, so that may be optional, but it's an extra bit of safety to use it.
posted by Sunburnt at 1:12 PM on December 24, 2020


Lanark's answer is probably the one I'd use, but if you don't know in advance how long exactly the file is to wait for it to finish playing you can get MPlayer, a command-line media player, for Windows. It will automatically exit once the track is finished.
posted by Aleyn at 1:45 PM on December 24, 2020


Response by poster: Update:
Batchfile containing:
taskkill /f /im wmplayer.exe

works nicely. The only thing that surprised me was that it took almost 30 seconds to shut it down. During which time I had already started swearing at the laptop. But that’s more about my patience than anything else.

Thank you all so much for helping me with this. I’d reached my limit on learning new stuff for the week and it is Christmas Eve. Big hugs to those who like big hugs.
posted by sciencegeek at 2:39 PM on December 24, 2020 [4 favorites]


If you are not committed to a computer for this task, an alarm clock with .mp3 capability or a cd player is designed to do exactly this task.
posted by theora55 at 8:21 PM on December 24, 2020


Response by poster: I’m fairly sure an mp3 alarm clock will not play a track or playlist for 8 hours and then automatically turn it off.
posted by sciencegeek at 9:01 PM on December 24, 2020


« Older Movies About the End of the World   |   Kaleidoscope of my dreams Newer »
This thread is closed to new comments.