Page 1 of 1
Batch is starting too fast after reboot
Posted: 31 Oct 2014 00:49
by stanian
So i have batch1 as this
Code: Select all
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /V 2 /D "%~d0\bat\batch2.bat /f
and then i reboot computer (windows8) and batch2 starts. It seems like the batch is starting before windows. Because ther is only a black background and the cmdwindow,
When i "x" the batchfile,windows contiune booting. My problem is that i need the computer connectet to internet to get my batch working. So i need the batch to load after the windows is finnish loading.
Any clue?

Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 01:20
by ShadowThief
Don't automatically start batch2.bat?
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 05:18
by Yury
Code: Select all
@echo off
set timeout=60
>nul timeout /nobreak /t %timeout%
::::::::::::::::::::::::::::::::::
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 10:04
by stanian
Yury wrote:Code: Select all
@echo off
set timeout=60
>nul timeout /nobreak /t %timeout%
::::::::::::::::::::::::::::::::::
But the windows wil not boot until the bach is closed.
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 10:06
by stanian
ShadowThief wrote:Don't automatically start batch2.bat?
If that was a solution i have noe created this post.
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 10:33
by Compo
Instead of running the batch file from the RunOnce key, add a self delete command to the bottom of it and place a shortcut to your batch file in the startup folder, "%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup".
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 11:00
by Yury
Compo wrote:Instead of running the batch file from the RunOnce key, add a self delete command to the bottom of it and place a shortcut to your batch file in the startup folder, "%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup".
"%AppData%\Microsoft\Windows\Start Menu\Programs\Startup"
Re: Batch is starting to fast after reboot
Posted: 31 Oct 2014 13:06
by stanian
Yury wrote:Compo wrote:Instead of running the batch file from the RunOnce key, add a self delete command to the bottom of it and place a shortcut to your batch file in the startup folder, "%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup".
This will not work for me because the batch is in diffrens path from pc to pc. (running from usb)
I got a answer from diffrent forum.
http://superuser.com/questions/834047/batch-is-starting-too-fast-after-reboot/834196#834196
Re: Batch is starting to fast after reboot
Posted: 15 Nov 2014 11:57
by Samir
I saw the solution from the other forum and it only introduces a delay in the execution of the batch file. But if what you really need to check is if there is Internet access you can use something like this:
Code: Select all
:CHKNET
echo.
ECHO Verifying Internet connection, please wait...
PING -n 1 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :CHKNET
Re: Batch is starting to fast after reboot
Posted: 15 Nov 2014 20:51
by Ed Dyreen
I believe windows starts your batch file and then waits for it to complete before loading the desktop and connecting to the internet. if you make the batch start another instance of itself and have the initial instance exit, windows will assume the batch has completed and should continue to load the desktop..
Code: Select all
if /I "%~1" neq "/NEXT" (
start /LOW /B "" "%~0" /NEXT
exit 0
)
echo. the initial batch process has exited, your code here..
Re: Batch is starting to fast after reboot
Posted: 15 Nov 2014 22:50
by Samir
Good thinking Ed, that's important too.
I assumed that problem was solved when the ping delay was hailed as a solution.
Re: Batch is starting too fast after reboot
Posted: 16 Nov 2014 23:48
by flippertie
Try a different approach:
Create a scheduled task to run the batch file, and set a trigger to run at log-on.
If you need it - under advanced properties there is an option to delay running the task. 30 seconds would probably work.