Tim Net Posted January 17, 2008 Share Posted January 17, 2008 Hello, I know how to make a script to play a sound file. I know how to load a script(.exe) as a Windows service. I'd like to have a service which does not require a user to be logged on yet can play music via the audio out jack on a laptop. While this might sound like a streaming app, it needs to run as a service(no user logged in) and is completely local to the single audio out(speakers) jack. How can I control a sound playing as a service? Thanks. Tim Link to comment Share on other sites More sharing options...
Tim Net Posted January 17, 2008 Author Share Posted January 17, 2008 This is bad for security. When I posted this, I figured that the most direct methods would not work. I figured that there must be some isolation when managing the sound between user mode (me opening Windows Media Player) and SYSTEM services using the _soundplay(). There is not. I added some logging as I expected to try and figure out why the sound file was not playing.I wrote a very small sound.au3 which just plays a filly pathed .mp3. #include <Sound.au3>$sound=_SoundOpen("D:\scripts\AutoIT\Audio\Do you hear what I hear.mp3")while 1 FileWriteline("D:\scripts\AutoIT\Audio\Activity.log",@hour & ":" & @min & ":" & @SEC & ",Start" ) $play = _SoundPlay($sound,0) FileWriteline("D:\scripts\AutoIT\Audio\Activity.log",@hour & ":" & @min & ":" & @SEC & "," & $play ) sleep(10000) $stop = _SoundStop($sound) FileWriteline("D:\scripts\AutoIT\Audio\Activity.log",@hour & ":" & @min & ":" & @SEC & "," & $stop )WEnd_SoundClose($sound)Compiled it and ran it in my session. No probem, I hear it.I then added an AT job to run the sound.exe via the scheduler under the SYSTEM account. 45 seconds later when the clock turned, the sound plays!at 5:49 D:\scripts\AutoIT\Audio\Sound.exeI then used inetsrv and srvany to load the sound.exe as a service called 'Sound'. Running as SYSTEM again, it played the music. @echo offcd /d "%~dp0"instsrv.exe Sound "%~dp0srvany.exe"reg add HKLM\SYSTEM\CurrentControlSet\Services\Sound\Parametersreg add HKLM\SYSTEM\CurrentControlSet\Services\Sound\Parameters /t REG_SZ /v Application /d "%~dp0Sound.exe"net start SoundI am perplexed that this is possible. Problem solved.Tim Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now