1.

Solve : Restarting widnows with a batch file?

Answer»

I WANT a batch file that will restart my computer ten times then stop. Is This possible if so how is it done?restart 10 times why? for what reason.. a little more detail and i might help u out..You could use a batch file to restart once (I don't THINK batch files can keep track of the number of times you have restarted, but feel free to correct as necessary) but it WOULD be a lot easier using a language such as VB or C(++) where you could make the appropriate calls or execute the shutdown (NT/XP) command. This would allow you to keep track of the number of times you have restarted in a file.

You would start the cycle by putting a link to the program in the Startup folder on the start menu.

At least that's how I'd do it...

Anyway, 10 times... why?I'm going to use it for computer repairs. When a computer comes into the STORE and it has boot problems. Thanks ill try doing it in VB.I don't think VB or C would be any easier than a batch file for this task ... at least not for Windows XP / 2003 / Vista. Try this:
Code: [Select]@echo off
if not exist C:\RebootCount.txt echo 1 >C:\RebootCount.txt
for /f %%a in (C:\RebootCount.txt) do set Reboots=%%a
if 0%Reboots% GEQ 10 goto :Done
set /a new=1+%Reboots%
echo %new% >C:\RebootCount.txt
shutdown -r -f -t 15 -c "Reboot number %Reboots%"
goto :EOF

:Done
del C:\RebootCount.txt
echo Reboots complete. Please remove Reboot batch file from Startup group
pause
Create a batch file with the code above, then copy it (or create a shortcut to it) to the Documents and Settings\All Users\Start Menu\Programs\Startup directory. Do the first reboot yourself, and it should take over from there.here is a code to restart newer Windows.

It wont restart 10 times but it will restart your computer for you.

SHUTDOWN -r -t 01
exit
Quote

I don't think VB or C would be any easier than a batch file for this task ... at least not for Windows XP / 2003 / Vista. Try this:
Code: [Select]@echo off
if not exist C:\RebootCount.txt echo 1 >C:\RebootCount.txt
for /f %%a in (C:\RebootCount.txt) do set Reboots=%%a
if 0%Reboots% GEQ 10 goto :Done
set /a new=1+%Reboots%
echo %new% >C:\RebootCount.txt
shutdown -r -f -t 15 -c "Reboot number %Reboots%"
goto :EOF

:Done
del C:\RebootCount.txt
echo Reboots complete. Please remove Reboot batch file from Startup group
pause
Create a batch file with the code above, then copy it (or create a shortcut to it) to the Documents and Settings\All Users\Start Menu\Programs\Startup directory. Do the first reboot yourself, and it should take over from there.


thank you GuruGary you are god in dos scripting Quote
I don't think VB or C would be any easier than a batch file for this task ... at least not for Windows XP / 2003 / Vista. Try this:
Code: [Select]@echo off
if not exist C:\RebootCount.txt echo 1 >C:\RebootCount.txt
for /f %%a in (C:\RebootCount.txt) do set Reboots=%%a
if 0%Reboots% GEQ 10 goto :Done
set /a new=1+%Reboots%
echo %new% >C:\RebootCount.txt
shutdown -r -f -t 15 -c "Reboot number %Reboots%"
goto :EOF

:Done
del C:\RebootCount.txt
echo Reboots complete. Please remove Reboot batch file from Startup group
pause
Create a batch file with the code above, then copy it (or create a shortcut to it) to the Documents and Settings\All Users\Start Menu\Programs\Startup directory. Do the first reboot yourself, and it should take over from there.





Thanks It worked GREAT.


Discussion

No Comment Found