Author Topic: Problems with Program autostart (used as SHELL:STARTUP)  (Read 5160 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Problems with Program autostart (used as SHELL:STARTUP)
« 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)
Code: QB64: [Select]
  1. ? "Program start"
  2.  

(Not running on my system)
Code: QB64: [Select]
  1. ? "Program start"
  2. SOUND 250 ,1
  3.  

« Last Edit: August 22, 2021, 10:04:09 am by Petr »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #1 on: August 22, 2021, 10:17:24 am »
Everything else has been loaded by Windows before you tried your program with sound?

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #2 on: August 22, 2021, 10:25:10 am »
 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

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #3 on: August 22, 2021, 11:58:42 am »
@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?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #4 on: August 22, 2021, 12:24:20 pm »
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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #5 on: August 22, 2021, 01:28:35 pm »

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?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #6 on: August 22, 2021, 01:34:39 pm »
A _SNDPLAY would probably use different drivers, the ones Windows might use at startup. Try that?

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #7 on: August 22, 2021, 01:51:16 pm »
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?

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #8 on: August 23, 2021, 09:53:29 am »
Has anyone tried it if his system behaves like mine?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #9 on: August 23, 2021, 09:56:24 am »
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.
Shuwatch!

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #10 on: August 23, 2021, 11:16:25 am »

Try the "double pocket"...
Create an exe program (without "sound") witch launches the main exe with the sound...
Why not yes ?

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #11 on: August 23, 2021, 11:20:02 am »
@euklides I don't think that would work still unless the drivers manage to load in-between loading the first exe and the second.
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #12 on: August 23, 2021, 12:23:07 pm »
From reading up on this on the web, the solution is to order your startup programs manually with a batch file.

Code: [Select]
@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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #13 on: August 23, 2021, 02:01:56 pm »
It looks like this solution might work. I'll try and let you know. Thank you, @SMcNeill.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problems with Program autostart (used as SHELL:STARTUP)
« Reply #14 on: August 23, 2021, 02:13:55 pm »
@SMcNeill Thank you very much, your solution works as expected. 3 seconds is enought, then  running all!