Jump to content

create computer restart loop for X times


shay
 Share

Recommended Posts

Hi

i wont to create a computer restart loop

witch in it a`ll have the ability to select how many restart will be preformed

is it passable :P

shay

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

yes it's possible. What are you creating this for?

I suggest taking a look at file writing and reading functions to do the counting.

i need this for testing purpose

i know that i need to do a loop how read counter from some log files

and after each restart it will write -1 in the log file

so when log file will get to 0 it will stop running the restart loop

how do i implant this?

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

First find yourself a piece of coding that will make this program run on startup... Or would you want to have to manually open your program every time you want to restart it?

[right]~What can I say, I'm a Simplistic person[/right]

Link to comment
Share on other sites

First find yourself a piece of coding that will make this program run on startup... Or would you want to have to manually open your program every time you want to restart it?

no problem

i use this to add Run Once in the registry

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "ewf", "REG_SZ", "c:\runonce.exe")

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

  • Developers

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

all of that info is very helpful

but i have some problem on the "conter"

with the read and write to the counter.....

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

Do you need this when the unit first starts, of after it is logged in? If after it is logged in, you could just place this compiled script in startup. Else you can put it in the path to it in the registry:

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "ewf", "REG_SZ", "c:\runonce.exe")

Just edit the ini to handle the number of reboots you need.

$path = "C:\restart.ini"
$ini = IniRead($path, "1", "1", "0")
if $ini => 1 then 
    $ini = $ini - 1
    IniWrite($path, "1", "1", $ini)
    Shutdown(6)  ;Force a reboot
endif
Link to comment
Share on other sites

  • Developers

all of that info is very helpful

but i have some problem on the "conter"

with the read and write to the counter.....

That is part of the examples... just be creative. :P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Do you need this when the unit first starts, of after it is logged in? If after it is logged in, you could just place this compiled script in startup. Else you can put it in the path to it in the registry:

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "ewf", "REG_SZ", "c:\runonce.exe")

Just edit the ini to handle the number of reboots you need.

$path = "C:\restart.ini"
$ini = IniRead($path, "1", "1", "0")
if $ini => 1 then 
    $ini = $ini - 1
    IniWrite($path, "1", "1", $ini)
    Shutdown(6)  ;Force a reboot
endif
Isnt the registry should be

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "ewf", "REG_SZ", "c:\runonce.exe")

Since runonce path registry means only run once then delete the registry path?

Link to comment
Share on other sites

Do you need this when the unit first starts, of after it is logged in? If after it is logged in, you could just place this compiled script in startup. Else you can put it in the path to it in the registry:

RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "ewf", "REG_SZ", "c:\runonce.exe")

Just edit the ini to handle the number of reboots you need.

$path = "C:\restart.ini"
$ini = IniRead($path, "1", "1", "0")
if $ini => 1 then 
    $ini = $ini - 1
    IniWrite($path, "1", "1", $ini)
    Shutdown(6)  ;Force a reboot
endif
thanks,

that work great and short my code to more "clean" one

i use the "REG run once" to run the code after restart.

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

thanks,

that work great and short my code to more "clean" one

i use the "REG run once" to run the code after restart.

after i develop the code some more a had some another problems,

after PC restart the firs thing that run is the code,

the problem is that the code wait to a specific window (WinWaitActive), the code pause all the programs in the start-up,

i need all the startup programs to load and then tell the code to wait to specific window,

no meter if i use sleep or WinWaitActive pause al programs during startup

$path = "d:\restart.ini"
$ini = IniRead($path, "restart_count", "restart_number", "0")
if $ini >= 1 then
    $ini = $ini - 1
    IniWrite($path, "restart_count", "restart_number", $ini)
    
;log file
    $file = FileOpen("d:\restart.log", 1)
    FileWriteLine($file, "Restart " &  @Hour & ":" & @Min & ":" & @Sec) 
    FileClose($file)
    
; REG insert
    RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce", "ewf", "REG_SZ", "d:\restart.exe")
    Sleep(200)
    Run(@COMSPEC & " /c ewfmgr c: -commitanddisable")
    sleep(200)
    MsgBox(0,'','Insert regestry OK ' ,2)
    Sleep(60000)
;Restart
    WinWaitActive(  "" , "connect")
    Beep(500, 500)
    Sleep(200)
    Beep(500, 500)
    Run(@COMSPEC & " /c shutdown -r -t 3")
    

Else 
Beep(500, 1000)
Sleep(200)
Beep(500, 1000)

$file = FileOpen("d:\restart.log", 1)
    FileWriteLine($file, "End of automation  restart " &  @Hour & ":" & @Min & ":" & @Sec) 
    FileClose($file)
    Sleep(200)
MsgBox(0,'','end of automation restart ' )

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

Why exactly are you wanting the computer to restart? There must be an easier solution I think...

Runonce will always be the first thing windows run after it start up.

Its mean only run one time only and will always be the first priority program to load, once executed whether successful or not, the runonce registry path will be deleted.

Thats why I suggested Run in the registry path instead of runonce.

This way, you could pause or sleep your program to wait until all apps in computer to load up. :P

Link to comment
Share on other sites

OK i found the problem

if i use run-once from the REG this is the firs application to load on windows,

if i run it from the start-up its last to load (in my case i use it)

"If the facts don't fit the theory, change the facts." Albert Einstein

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...