Playing sound in HTA across network share

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
screwloosedan
Posts: 2
Joined: Tue Feb 15, 2011 4:11 am

Playing sound in HTA across network share

Post by screwloosedan » Wed Feb 16, 2011 3:41 am

I accidentally posted this same question in the wrong section yesterday...sorry for cross posting (and the other section doesn't allow me to move or otherwise modify).

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">&nbsp;</span> 
</body>

User avatar
screwloosedan
Posts: 2
Joined: Tue Feb 15, 2011 4:11 am

Playing sound in HTA across network share

Post by screwloosedan » Mon Feb 21, 2011 10:15 pm

jvierra - Thanks for the reply and help. Your solution is working much better for me.As a side note "C:WindowsMediaRingin.wav" does not exist on my Vista Enterprise (SP1 32b) build nor my Win 7 Home Premium (64b). "C:WindowsMediaWindows Ringin.wav" does exist on both.

Locked