Windows Media Encoder Startup Script
If you have a critical encoder streaming live audio for an Internet radio station or maybe video for a presentation then you want that encoder to be running all the time and you shouldn’t have to login and restart the encoder manually if the host computer loses power or reboots. The Windows Media Encoder has a wonderfully simple graphical user interface but unfortunately you cannot directly configure it as a service to run in the background when the host starts up. Fortunately Microsoft provides a command line script that you can use to start an encoding session on boot-up.
Requirements:
- Windows 98, ME, NT, 2000, 2003, XP
- Windows Media Encoder (preferably version 9) Download
- Windows Media Encoder Series SDK (preferably version 9) Download
- Windows Media Encoder Session File (*.WME) configured for your stream
Setup:
- Download and install the WME Series SDK somewhere on your computer.
- Create a convenient folder to store your files on your hard drive, I recommend “C:\WME”
- Open the SDK folder and find the file called “Wmcmd.vbs”. If you installed in the default path it will be under “C:\WMSDK\WMEncSDK9\samples\vb\wmcmd” Copy this file to your new WME folder.
- Create your Session file using the WME graphical interface and save it to your WME folder.
- Open Notepad (under Programs | Accessories) and enter a line such as the following, substituting the correct file names and paths:
cscript.exe path_to_wmcmd.vbs -wme path_to_session_file
For example:
cscript.exe C:\WME\wmcmd.vbs -wme C:\wme\stream1.wme
Note: for Win 98 and ME you may get away without the preceeding "cscript.exe" or you can try just "script.exe"
- Save the file with the .BAT extension. The easiest way to do this is to put quotation marks around the file name in the Notepad dialog box. For example type “encode.bat” with the quotes.
- Test the new .BAT file by finding it with My Computer or Explorer and double clicking it. A black DOS box should open and periods (.) should start to appear as encoding progresses. Check to make sure you can access your stream.
Now there are two ways to make your .BAT file start automatically without anyone having to logon.
I’ve tried this and unfortunately I couldn’t get it to work. My vbs file was found at C:\WMSDK\WMEncSDK9\samples\vb\wmcmd\Wmcmd.vbs and I placed my .bat file and .wme files directly on the C drive. Any suggestions?
So your .bat file might look like:
cscript.exe C:\WMSDK\WMEncSDK9\samples\vb\wmcmd\Wmcmd.vbs -wme C:\mystream.wme
and what happens when you try to run it by double clicking? When it works correctly, you should see a series of periods progressing across the window. I’ve had issues with PUSH streams that have to login to the server so that may be your problem.
hi, is there a way of creating a script to automate this with a Push stream that needs to log on, I run an internet radio and want my djs to be able to kick of a live broadcast with a double click and thats it…
Thanks in advance
HI TRTR, I just posted a tutorial on how to modify the WME file so that you can broadcast a PUSH stream with authentication so that should help. As for starting the feed, you can just save the .BAT file to your desktop and have the DJs double-click the file to start encoding. Let me know how that works out.
Thank you admin for your quick response, i have now edited the .wme file but still no luck.. my .bat file reads like this “cscript.exe c:\WME\Wmcmd.vbs –wme c:\WME\LIVEHQ.wme” i have tried running this line in the cmd prompt and get the error”invalid parameter -wme” also when i run the livehq.wme by itself, it still asks for me to click ok on the login box (username and pwd are saved as always), didnt know if it was normal and it would auto authenticate when run with the wmcmd.vbs and .bat file… ive hit a brickwall with this and really appreciate your help, thanks again..
Hi again, sorry for the delay. Do you have a non-password protected stream to test the VB script with? Also, try creating a simple WME file that encodes a static media file to something else and run it with your .bat to see if it works. And are you running as admin if you’re on a Vista or Win7 machine? ~Chris
Thank you for posting this information. i can’t believe how scarce information on Windows Media CMD encoding is on the web. I have been able to successfully use the info about as well as the Username and Password authentication. By successful I have received the ‘periods’ in the CMD window, however I have not been able to access my streams with any success. Do you have any ideas as to why I am not able to connect to my streaming server? Using the WME gui I can successfully connect and stream but not using the CMD line.
-Jr
Hello Jr, so you can run the same WME file from the GUI and you can connect to the stream but if you run from the command line you can’t connect? It could be a username issue if you are trying to run the script under a non-administrator account. Try logging into the Windows machine where you are running the script as a local administrator account. Then start a command line and manually run the script and see if that works. I noticed that if I ran the script as a service in Firedaemon it wouldn’t work with some of the different accounts. I have to go back and troubleshoot to see which one actually worked.