Microsoft KB Archive/290898

= How to Create Windows Media Encoder Files with WSH =

Article ID: 290898

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Windows Media Encoder 7.0
 * Microsoft Windows Media Encoder 7.1

-



This article was previously published under Q290898



SUMMARY
This article describes how to automatically create a Windows Media Encoder configuration file (.wme) with Windows Scripting Host (WSH).



DISCLAIMER
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

CODE SAMPLE
To use this sample, copy the WSH code into Notepad, and then save it in a folder containing .wma, .wav, or .mp3 files as &quot;Makewme.vbs&quot;. To run the sample, double-click the file that you saved. The example code will automatically create a .wme file that you can open with the Windows Media Encoder. Option Explicit

' ********** define all variables **********

Dim objFSO Dim objFolder Dim objFile Dim objWME Dim strExt Dim strName Dim strGUID

' ********** Verify WSH Version **********

' minimum Windows Script Host (WSH) level Const intMinWSH = 5 ' check for WSH version and exit if to old If CLng(WScript.Version) < intMinWSH Then MsgBox &quot;You must have at least Windows Script Host version &quot; & _ intMinWSH & &quot; to use this script.&quot;, vbCritical, &quot;WSH Version Error&quot; WScript.Quit End If

' ********** define some general constants **********

' valid file extensions to search for Const strValid = &quot;.wma.mp3.wav&quot; ' broadcast port Const intPort = 1755

' ********** set encoder level **********

' Near-CD Quality (64kbps) Const str64KBPS = &quot;GUID {B29CFFC6-F131-41DB-B5E8-99D8B0B945F4}&quot; ' CD Quality (96kbps) Const str96KBPS = &quot;GUID {A9D4B819-16CC-4A59-9F37-693DBB0302D6}&quot; ' CD Quality Transparency (128kbps) Const str128KBPS = &quot;GUID {C64CF5DA-DF45-40D3-8027-DE698D68DC66}&quot; ' set the encoder to 128kbps (change to desired level) strGUID = str128KBPS

' ********** create the WME file **********

' get a File System Object to use Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;) ' get an object for the current folder Set objFolder = objFSO.GetFolder(&quot;.&quot;) ' create a WME file named after the folder Set objWME = objFSO.CreateTextFile(objFolder.Name & &quot;.wme&quot;,True,True)

' start the WME code, using the folder name as the title objWME.WriteLine &quot;&quot; objWME.WriteLine vbTab & &quot;&quot; objWME.WriteLine vbTab & &quot;&quot; objWME.WriteLine vbTab & &quot; &quot; objWME.WriteLine vbTab & vbTab &vbTab & &quot;&quot; objWME.WriteLine vbTab & vbTab & &quot;&quot; End If End If Next

' end the WME code, using the intPort constant for the broadcast port objWME.WriteLine vbTab & &quot;&quot; objWME.WriteLine vbTab & &quot;&quot; objWME.WriteLine vbTab & &quot;&quot; objWME.WriteLine &quot;&quot;

' close the WME file objWME.Close

Additional query words: netshow WME WSH

Keywords: kbinfo KB290898

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.