The PA System run WAV files at a specified time using task scheduler. This just opens the default player (windows media player in this case) and runs the file. This means that the user must be logged into the system to run so if you setup RDP you will have to just disconnect (do not logout). I also created a Web Based UI using XAMPP for Windows as the base Apache 2 install with minimal settings. I've also used a 3rd party plugin called nircmd. This allowed me to make a php file to run a mute/unmute command. This machine has no access to the internet and is only accessible from the intranet due to security concerns.
Task Scheduler with the wave file schedule |
Web Directory |
nircmd.exe mutesysvolume 0 - Sound is Enabled
nircmd.exe mutesysvolume 1 - Sound is Muted
The PHP files for enabling and disabling the sound are seperated out from the index.php file because it would run the mute/unmute commands when loading the page. Lets go over the index file first. We have the index file loading a txt file with a true or false value. The sound is either on or off. The we use a simple if statement to display if we are displaying the sound is on or off.
Code for the index.php file |
PHP Files for enabling and disabling sound |
system('cmd /c $YOURPATHTONIRCMD.EXE mutesysvolume 1');
as I described above this is the command for muting the sound, using the NIRCMD utility.
Then I built used a responsive web based UI for enabling and disabling the sound.
PA System Desktop Showing Sound Enabled |
PA System Desktop Showing Sound Disabled |
PA System on Mobile |
To reset the PA System Audio to enabled I setup a task scheduler event to run a bat file that runs nircmd.exe mutesysvolume 0 at 6:00 am. With this in mind you also need to update the soundstatus.txt file so when the GUI load it registers that the sound has been re-enabled. To do that I decided to use powershell, specifically the Out-File utility.
"on" | Out-File $PATHTO\TEXTFILE.txt
Now by doing this if I want to run it as a .ps1 file I need to allow powershell scripts to run the powershell scripts you run powershell as an administrator and
Set-ExecutionPolicy Unrestricted
Now this IS a security risk and I will be looking to make something that is more secure in the future, in the mean time it is a stopgap measure that his acceptable since the access to the device is intranet on port 80 and RDP only. The script above leaves some forward character garbage so I also changed the lookup logic of the PHP file to look and see if the sound is off. This way be default it assumes the sound is on, and only checks to see if the sound has been disabled.