Though I could easily have implemented it as a Visual Basic script, I prefer a compiled EXE because its use does not depend upon a working Visual Basic Scripting interpreter, which is not a given in some locked down environments. Nevertheless, for fun, below is my improved implementation, which took maybe an hour to cobble together and test.
Option Explicit
' ============================================================================
'
' Script Name: SoundOff.VBS
'
' Objective: Cause a shell script to play a sound file to completion.
'
' Command Arguments: SoundFileName = Name of sound file to play
'
' Remarks: This script is a port of SountOff.exe.
'
' ----------------------------------------------------------------------------
' Revision History
' ----------------------------------------------------------------------------
'
' Date By Synopsis
' ---------- --- -------------------------------------------------------------
' 2018/05/28 DAG Script created, tested, and deployed
' ============================================================================
const ARGS_NONE = 0
const ARRAY_FIRST_ELEMENT = 0
const ERROR_SUCCESS = 0 ' The status code variable is initialized with the standard Windows "success" status code.
const ERROR_NEEDS_CSCRIPT = 1 ' Status code 1 is reserved for scripts run in Wscript that require CScript.
const ERROR_NO_ARGS = 2 ' Status code 2 is reserved for scripts that require one or more command line arguments to report being called without any.
const ERROR_FILE_NOT_FOUND = 3
const SLEEP_TIME_100_MILISECS = 100
const WMP_PLAY_STATE_STOPPED = 1
dim intExitCode : intExitCode = ERROR_SUCCESS ' Anticipate success.
dim oArgs : Set oArgs = WScript.Arguments
dim iArgLast : iArgLast = oArgs.Count
if iArgLast > ARGS_NONE then
dim sFileSpec : sFileSpec = oArgs ( ARRAY_FIRST_ELEMENT )
dim oFSO : set oFSO = CreateObject ( "Scripting.FileSystemObject" )
if oFSO.FileExists ( sFileSpec ) then
dim oPlayer : Set oPlayer = CreateObject ( "WMPlayer.OCX" )
oPlayer.URL = sFileSpec ' Define the location / name of the file.
oPlayer.controls.play