0

I have a set of programs running at Windows startup, some called from Registry and others called from Start Menu (Initialization).

I'm trying to have a batch file loaded and showed its screen AFTER all other programs has had loaded.

I tried changing their entries in Registry (Run subkey, also Wow6232Node) and Start Menu without success. That batch file is almost always the first screen I got and it is not desirable as I need. It has to be the last screen showed. Firefox uses to be the last one.

So, how to load Firefox (and all others) BEFORE that batch file? How to delay or put a "sleep" command within Windows start up for a given program?

I'd add that important thing is to set focus to batch file running after all other programs had loaded. My goal is to have that batch file in foreground and focused.

  • 1
    Why don't you simply google for windows 7 program startup order? The first result could answer under the Using a Batch Script header. Another approach: trigger a scheduled task on startup + some delay. Yet another thought: instead a fix delay, check whether desired tasks run using tasklist or wmic process... – JosefZ Oct 27 '15 at 17:39
  • Thanks, JosefZ. Your suggestion "Using a Batch Script" had solved the question. I used a script with "timeout /t 15" batch command and it runs fine. Searching around, I also found that "PING 111.111.111.111 -n 1 -w 15000 >NUL" has the same effect. I needed to use "start" command too. Interesting tip about Scheduled Task, but "timeout" was enough. – Gabarito007 Oct 27 '15 at 23:50
0

For those users with the same question on how to put a delay, after some searching and JosefZ's tips above, my script is this:

@echo off
rem PING 111.111.111.111 -n 1 -w 15000 >NUL
timeout /t 15
"C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPtray.exe" /m "somefile.pgd"
start C:\somefolder\somefile.exe
exit
  • The last two lines: remove start, and that allows you to remove exit on the last line – Canadian Luke Oct 28 '15 at 0:08
  • Yes, I can remove start, but I cannot remove exit because it closes CMD window. I thought that start was needed because it waits for user's input, but I saw that it isn't necessary, as you said. – Gabarito007 Oct 28 '15 at 8:28
  • You can use start /w to wait for the program to terminate... You can also use an & after a command to skip to the next line right away, closing the window – Canadian Luke Oct 28 '15 at 13:25
  • @Canadian Luke - I noticed that if I remove start, CMD window never closes, EVEN with exit command present. If I put command start, CMD window closes after +- 30 seconds. Why it happens? How to close it immediately after user input? Explaining better: After timeout line, I mount a PGD volume. So, I enter passphrase and run a program inside that volume. This time, I use start command. I cannot go right away to run the program because volume is not mounted yet. – Gabarito007 Oct 28 '15 at 16:08
  • Everything is OK now, but CMD window is delaying to close. Why? How to close it immediately after user input? Curiously, if I run batch file with double click, it closes right after user input. But if runs at Windows startup (Registry key "run"), CMD windows delays to close. Weird. – Gabarito007 Oct 28 '15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.