Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

create computer restart loop for X times


  • Please log in to reply
15 replies to this topic

#1 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 15 March 2009 - 02:43 PM

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







#2 toonboon

toonboon

    Prodigy

  • Active Members
  • PipPipPip
  • 174 posts

Posted 15 March 2009 - 02:45 PM

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.

~What can I say, I'm a Simplistic person


#3 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 15 March 2009 - 02:57 PM

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

#4 toonboon

toonboon

    Prodigy

  • Active Members
  • PipPipPip
  • 174 posts

Posted 15 March 2009 - 03:02 PM

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?

~What can I say, I'm a Simplistic person


#5 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 15 March 2009 - 03:20 PM

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

#6 toonboon

toonboon

    Prodigy

  • Active Members
  • PipPipPip
  • 174 posts

Posted 15 March 2009 - 03:24 PM

FileRead(blahblah)
FileWrite(blahblah)
some code for restart.

Voila you're finished.
throw in some if... then... else... endif in there and you're set.

~What can I say, I'm a Simplistic person


#7 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,479 posts

Posted 15 March 2009 - 03:26 PM

Study this example:
http://www.autoitscript.com/forum/index.ph...mp;#entry653631

Jos :P

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#8 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 15 March 2009 - 03:46 PM

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

#9 Bert

Bert

    Why yes....

  • MVPs
  • 12,127 posts

Posted 15 March 2009 - 04:03 PM

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


#10 Jos

Jos

    Je maintiendrai

  • Developers
  • 23,479 posts

Posted 15 March 2009 - 04:20 PM

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

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#11 firsttimer

firsttimer

    Seeker

  • Active Members
  • 27 posts

Posted 15 March 2009 - 05:59 PM

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?

#12 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 16 March 2009 - 06:52 AM

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

#13 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 16 March 2009 - 12:02 PM

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

Plain Text         
$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

#14 toonboon

toonboon

    Prodigy

  • Active Members
  • PipPipPip
  • 174 posts

Posted 16 March 2009 - 04:27 PM

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

~What can I say, I'm a Simplistic person


#15 firsttimer

firsttimer

    Seeker

  • Active Members
  • 27 posts

Posted 16 March 2009 - 05:50 PM

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

#16 shay

shay

    Wayfarer

  • Active Members
  • Pip
  • 69 posts

Posted 17 March 2009 - 05:45 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users