QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Petr on August 22, 2021, 10:02:00 am
-
Hi guys, as you know, I'm dealing with a program that starts automatically when windows starts. I wrote it and suddenly ... the programs stopped running on their own, windows just didn't start them for some reason. I found out the reason and it turns out that if the EXE file contains the SOUND command, then such a file simply will not run. So I didn't try other audio commands. I assumed that the sound card was already initialized after starting the system and entering the password. Does anyone have any tips on what to do with it?
All you need to try is this code:
(running on my system after windows start)
(Not running on my system)
-
Everything else has been loaded by Windows before you tried your program with sound?
-
Very interesting, @Petr. I will play around with this when getting back home today and see what happens on my system.
Have you tried putting a pause in the program before the SOUND command is called, just to see if one is needed to let the system init the sound card?
- Dav
-
@Petr
In Windows 10 there are two different folders which can be used for use with auto-startup.
Which folder (if any) are your auto-startup .exe's located?
-
If it’s some sort of race condition going on at start up time (such as sound trying to play before sound drivers are loaded), then try to add a _DELAY to your program before the SOUND statement. See if that makes any sort of difference at all.
-
I tried adding _DELAY 1, it didn't help. However, the sound card should be initialized at the time of running this program, because when Windows 7 starts, the first sound chime goes before entering the password into the system, only then does this program start, it is true that at the same time another sound plays in windows - after starting system. The expected output, even if there is a problem with the sound, would be running the program without sound - not that the program will not start at all. I try then to add a pause 10 seconds after the start (_DELAY 10), the introductory sound is be played ... but this program is not run. So - maybe, if in program start is already sound card used, maybe your 3rd party sound software close the program?
-
A _SNDPLAY would probably use different drivers, the ones Windows might use at startup. Try that?
-
Thanks for idea, @bplus,
I found out the following. If I add a music file to the folder after startup, Windows media player will start automatically - but also all other files that use sound. If I remove the music file from the folder after running, only those programs that do not use sound will run (I tried SOUND, BEEP, _SNDPLAYFILE). Looks like I have a bug in the system configuration that is fixed by running Windows media player. Does anyone have any idea what this could cause?
-
Has anyone tried it if his system behaves like mine?
-
I'm in agreement with Steve about the race condition with sound drivers. If you notice, the sounds in Windows are loaded rather late in the bootup. You won't see the speaker icon appear for a while. When it first shows, it has a red X through the speaker icon because the drivers are still loading. I'm not sure how you could check that the drivers are available first, though.
-
Try the "double pocket"...
Create an exe program (without "sound") witch launches the main exe with the sound...
-
@euklides I don't think that would work still unless the drivers manage to load in-between loading the first exe and the second.
-
From reading up on this on the web, the solution is to order your startup programs manually with a batch file.
@ECHO OFF
TIMEOUT /T 10
REM Total Delay = 10 seconds
START “” “C:Program Files (x86)Microsoft OfficeOffice14OUTLOOK.EXE”
TIMEOUT /T 20
REM Total Delay = 30 seconds
START “” “C:Program Files (x86)Microsoft OfficeOffice14WINWORD.EXE”
START “” “C:Program Files (x86)CitrixGoToMeeting457g2mstart.exe”
TIMEOUT /T 20
REM Total Delay = 50 seconds
START “” “C:Program Files (x86)Microsoft OfficeOffice14EXCEL.EXE”
Use TIMEOUT and START to specify delay and program to execute, and put the batch file in your startup folder, rather than the program itself.
If your system is like mine, the sound drivers don’t load until towards the end of the bootup process, and it’s handled by software rather than hardware drivers. (Realtek audio software, in my case.). A hardcoded timeout to delay long enough for those drivers to load might fix the issue, or you may be able to search for them via process name in the task manager and wait to execute the program with sound until after they’re loaded.
-
It looks like this solution might work. I'll try and let you know. Thank you, @SMcNeill.
-
@SMcNeill Thank you very much, your solution works as expected. 3 seconds is enought, then running all!
-
Glad to hear you got it working. ;D