Part 2/2. Continuing below...

Then, I happened upon the quaint idea of using

tscon %sessionId% /dest:console

to "repoint", or reorient an active RDP session to instead targe the "console", a sort of persistent virtual terminal session that the computer always has. From the days of when people actually sat in front of the machines they were using. Physically, like.

I thought that if I could send my RDP session to console then it would live. It would be alive!

And it was. But the audio still died.

All the while, I was context switching out of RDP back to my macOS desktop, to check my BrowserBox connection open in a regular browser tab. Every time, no matter what weird configurations, registry settings, or supposed ways to change various settings related to RDP, nothing worked. Every time audio still died.

This was quite possible the biggest, craziest bug I ever worked on. (Interestingly enough the second biggest, craziest bug I ever worked on was also audio related).

But maybe it wasn't a bug. Maybe it just wasn't to be. Perhaps the gods willed it to be not so. None shall ever, from now until the ashes fall upon the ghost of the world, and time stands finally still, stream audio from Windows Server without a real RDP connection.

It was during this period I also discovered the idea of a Windows Session Host server with Client Access Licenses. Turns out, you need to purchase a RDP license from Windows if you want more than 2 RDP sessions (approximately) to the same OS instance/VM.

Turns out, too, that this notion was not related at all to getting audio to work.

It really seemed like I'd never get there. I was starting to think: Cut my losses, abandon it. It was a nice dream, shame it didn't work out, but that's what happens sometimes.

One day, I woke up with a hunch, that if I could someone use VNC at the same time as RDP, perhaps I could trick the repointed console session into staying alive. I didn't know how or why this should happen, but it just seemed like: it should, somehow. As if through all my intense working with Windows, it was somehow whispering to me, telling me how it wanted to be treated. As if Windows itself wanted this to occur, and somehow through all the interacting with it, I'd absorbed that message. And figured it out. I knew I was onto something with this. Momentum, and optimism, returned. I felt re-energized. I began to feel like this was possible. But still, I had no idea how to do it.

Turns out, I eventually figured it out. And made it repeatable. And further that it worked on: Windows Server 2022, Windows Server 2019. It also, IIRC, worked on Windows 10 and Windows 11.

I formalized it all into a ridiculous PowerShell script where nothing now seemed impossible (so I went so far as to even use crazy C#-in-PowerShell hacks to close windows automatically as part of the install process, just to ensure that all that epic work, 10 hour days, maybe for over two weeks or more, were not wasted. And finally I ended up with a script that actually managed to both install BrowserBox, and set up the required VNC/RDP dance needed to keep the Windows audio drivers active, even when I do not have an RDP connection.

It was kind of complex, and like synchronized swimming, depended crucially on the order of the orchestrated VNC and RDP connections, and what was done in each session, but roughly, the process the enable audio on Windows versions, went like this:

- Create an initial RDP connection to the Windows based server for setup.

- Set up the application by performing a normal install of BrowserBox

- Open up registry key settings enabling: multiple (the maximum allowed for free, which is 2) sessions; and connecting to localhost

- Also set up a login script that will perform "The Magic Task" described below.

- Install VNC, and configure it with a password. From within that RDP session, create a VNC connection from that Windows server to itself, and ensure that VNC window is open and not minimized.

- From within that loopback VNC session just created, execute the logon script (which will happen automatically) to perform the Magic Task. The Magic Task is: use tscon to repoint the current main active RDP connection (from my local computer to this remote Windows machine) to instead point at console, disconnecting me, and creating a ourobouros-double-loopback-VNC-RDP-ying-yang super session that is self-stabilizing and crucially (Crucially! because at that point it had been 3 weeks of effort!), keep the audio streaming

The music might die one day. But not today.

I managed to factor out this code into a relatively reusable-esque script that I called Thunderbird (because I was so in awe of myself at that point haha!)

You can see the code here:

https://github.com/BrowserBox/BrowserBox/blob/boss/windows-s...

Postscript

Turns out tho, despite all that effort, Windows was never a very popular target for BrowserBox. Sure, good to prove that it works there and provide a first blush at support, but in the end, not that many people use Windows to run BrowserBox. As proud as I am of that achievement, I can't even guarantee the method described still works today. The script had so many moving parts, I imagine it would be pretty fragile. Also, I have a suspicion that, as of this post today, Microsoft may hear this and want to lock down this seeming workaround because, even tho I don't think there's a way to use it to get more RDP connections that licensed, it sort of seems like something that shouldn't be possible, so I'm kind of worried they will just stamp it out.