I have a need to play a sound from within an HTA. To keep it simple
and so multiple users can use it I would like to 1 - Use a default
windows sound and 2) Be able to run the HTA from a network share.
This
seemed simple enough, but it doesn't appear to work. A possible work
around includes putting a sound file on the network share, but I wanted
to reduce the chances of someone messing this up.
When running this across a network share I receive no error, but also no sound. If I run this locally, it works as expected (plays sound).
Here's sample code of what I'm trying to do (obviously the real HTA is a bit more involved):
Code: Select all
<html>
<title>My HTA</title>
<HTA:APPLICATION
ID="objMyHTA"
APPLICATIONNAME="MyHTA"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<!-- ************************* -->
<head>
<script language="vbscript">
Sub Window_OnLoad
strHtml="<embed src=" & chr(34) & "C:WindowsMediaWindows Ringin.wav" & chr(34) &" autostart=true width=0 height=0 id=" & chr(34) & "alarmsound" & chr(34) & "playcount=" & chr(34) & "10" & chr(34) & " HIDDEN="& chr(34) &"true" & chr(34) & ">"
strhtml=strHtml & "
Message! You should hear an alarm."
error.InnerHTML=strHtml
End Sub
</script>
</head>
<!-- ************************* -->
<body>
<span id="error"> </span>
</body>