Search code examples
winapiaudioremote-desktopbeep

Console.Beep() - sound is not redirected through RDC


I have a Windows program that uses the Win32 Beep(frequency, duration) function to alert a user when something important is happening.

Now one of my users is Remote Desktop Connecting to a virtual machine, and running the application there. Other sounds are properly being redirected (like playing WAV files for instance). However, the beep is not redirected. I've even created a simple test program, all it does is make one tone, and sure enough, it only tones when run on my local machine. Run on any computer I Remote Desktop Connect to, and it runs silently.

If there is a way to "turn this on", that would be great. If not, I'll put in a change request to alter the application to play a wav file instead of using the built in beep function.

If interested - here is the super simple console app I used to to test (Visual Studio/C#)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeepTester
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press a key to continue and play a short beep...");
            Console.ReadKey();
            Console.Beep(1500, 300);
            Console.WriteLine("All done, Press a key to exit...");
            Console.ReadKey();
        }
    }
}

Solution

  • Further investigation shows that there is a service called "Beep" that must be running to convert this particular API call, which used to be hardware related, to a tone through the sound output of choice.

    For some reason, when the OS was installed on the VM (seems to be the default?), the beep service is set to manual startup. When I manually typed "NET START Beep" as an administrator, the sound works.

    One can edit the registry to make the Beep service run automatically at startup in the VM, and the problem is then solved permanently.