Jump to content

autoit script to ask restart or not ?


Recommended Posts

what is the autoit script to ask

"your computer need to restarted once, press Yes to restart the computer and No to cancel"


if yes is clicked it should restart the PC

if no is pressed , dialogue box should be disappeared

and if nothing is clicked for 1 minute it should be able to restart the PC automatically.

Link to comment
Share on other sites

I came up with this script that runs shutdown.exe but I

don't know how or if its even possible to not have the

shutdown.exe window pop up. setting the timeout to 1 is

the best I could do. If you leave it off it defaults to 30

seconds. I didn't try setting it to 0

Dim $value
Dim $yes
Dim $no
dim $value
dim $timeout
dim $nobutton
$yes = 6
$no = 7
$nobutton = -1
$value = MsgBox(4,"Restart required","Click yes to restart No to cancel",60)
If $value = $yes or $value = $nobutton Then
Run("shutdown.exe -r -t " & $timeout)

Link to comment
Share on other sites

I use a 10 minute timeout. If I do not attend the PC, then it will shutdown. A simple messagebox takes care of it. I run an Au3 script from the RunOnce key to take care of shortcuts, possible windows, change ini settings for RainLendar and then perform a countdown for the shutdown.

Timeout Messagebox

; First Logon Script.

; enable adlib.
; lets sleep alittle and give the desktop a chance to setup.
; remove read only attributes.
FileSetAttrib(@UserProfileDir & '\*', '-R', 1)

#region - Alter Rainlendar position in it's ini file
Func _Rainlendar()
Local $width = @DesktopWidth
Case $width = 640
Local $x = 469
Case $width = 800
Local $x = 619
Case $width = 1024
Local $x = 840
Case $width = 1280
Local $x = 1084
Case $width = 1600
Local $x = 1429
Case Else
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'X', $x)
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'Y', 15)
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'TodoX', $x+10)
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'TodoY', 184)
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'EventListX', $x+10)
IniWrite(@AppDataDir & '\Rainlendar\Rainlendar.ini', 'Rainlendar', 'EventListY', 242)

#region - Remove shortcuts
; all user startmenu shortcuts
If FileChangeDir(@StartMenuCommonDir) Then
FileDelete('Set Program Access and Defaults.lnk')
FileDelete('Windows Catalog.lnk')
FileDelete('Windows Update.lnk')
; all user startmenu \ programs shortcuts
If FileChangeDir(@ProgramsCommonDir) Then
FileDelete('Windows Movie Maker.lnk')
FileMove('Windows Messenger.lnk', 'Accessories\Communications\Windows Messenger.lnk')
; current user desktop shortcuts
If FileChangeDir(@DesktopCommonDir) Then
FileDelete('Internet Explorer.lnk')
FileDelete('Outlook Express.lnk')
; current user startmenu \ programs shortcuts
If FileChangeDir(@ProgramsDir) Then
FileDelete('Internet Explorer.lnk')
FileDelete('Outlook Express.lnk')
FileDelete('Windows Media Player.lnk')
FileDelete('Accessories\Program Compatibility Wizard.lnk')
FileDelete('Accessories\Tour Windows XP.lnk')
FileMove('Remote Assistance.lnk', @ProgramsCommonDir & '\Accessories\Communications\Remote Assistance.lnk')

#region - Give option to not shutdown
$option = MsgBox(4, 'Installation is fully complete', 'System will shutdown within 10 minutes, unless No is pressed', 600)
; disable adlib
; process option
Case $option = -1
Case $option = 6
Case Else


Func _AdLib()
; scan for unexpected events
If WinExists('Windows Security Alert') Then
If Not WinActive('Windows Security Alert') Then WinActivate('Windows Security Alert')
If WinExists('avast! Home Edition Info') Then
ControlClick('avast! Home Edition Info', '', 'Button1')

Link to comment
Share on other sites

Why use shutdown.exe when AutoIt supports its own shutdown function?

Thanks, I was wondering about that. searched for it in help, guess I didn't search very good. Now I go to search in autoIt help and find it right away.

Mmm must have been half asleep before.

Just tried my script using autoit's shutdown function. works much better

Edited by jbm
Link to comment
Share on other sites

; Author:        bhurte_p@hotmail.com (Pawan Bhurtel)

$answer = MsgBox(4, "Windows XP|Restart|", "Your computer need to be restarted once to fully update ur system. Do u want to restart ur computer ? Or will automatically restart after 1 minute.", 60)

If $answer = 7 Then




most simplest one,, what u r looking for .... :)

Edited by Nepali
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

  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Create New...