Jump to content

Autoit scripts at runonce


Recommended Posts

Just out of interest, put a sleep delay of about 1 minute before any of your code (top line)

That way the PC will have time to get itself sorted before running the script.

Try it and see if that helps ...

ive tried it in HKLM runonce & runonceEX but it wont run. ive also tried in HKCU rinonce which runs once into windows but this dosent run either.

the script is compiled to defrg.exe in the windows\system32 directory. it runs in windows but not in any runonce.

Link to comment
Share on other sites

Here is the script

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

$started = 1

$mainwindow = GUICreate("Defragmentation", 200, 100)

GUICtrlCreateLabel("Automating defrag in 6 seconds", 30, 10)

$btnExit = GUICtrlCreateButton("Skip", 70, 50, 60)

;GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

GUICtrlSetOnEvent($btnExit, "_Terminate")

GUISetState(@SW_SHOW)

While 1

Sleep(6000)

If $started Then

Run("defrag.exe c: -f", "", @SW_HIDE)

EndIf

Exit

Wend

Func _Terminate()

$started = 0

Exit

EndFunc

here is runonce

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Applications" /f

REG ADD %KEY%02 /VE /D "BTS Driver Pack Finisher" /f

REG ADD %KEY%02 /V 1 /D "%SystemDrive%\DPsFnshr.exe" /f

REG ADD %KEY%02 /V 2 /D "reschangecon.exe -width=1024 -height=768 -depth=32" /f

REG ADD %KEY%15 /VE /D "McAfee VirusScan Enterprise 8.0" /f

REG ADD %KEY%15 /V 1 /D "%systemdrive%\install\VE8.0iPatch13\setup.exe /qb" /f

REG ADD %KEY%15 /V 2 /D "%systemdrive%\install\sdat4944.exe /silent" /f

REG ADD %KEY%25 /VE /D "Adobe Reader 8.0" /f

REG ADD %KEY%25 /V 1 /D "%systemdrive%\install\reader8.exe" /f

REG ADD %KEY%50 /VE /D "Macromedia Shockwave 10.0.1" /f

REG ADD %KEY%50 /V 1 /D "%systemdrive%\install\Shockwave10.exe" /f

REG ADD %KEY%60 /VE /D "Cleanup" /f

REG ADD %KEY%60 /V 1 /D "REGEDIT /s %WINDIR%\system32\regcleanup.reg" /f

REG ADD %KEY%60 /V 2 /D "%WINDIR%\system32\cleanup.cmd" /f

REG ADD %KEY%70 /VE /D "Defragmentation" /f

REG ADD %KEY%70 /V 1 /D "%WINDIR%\system32\defrg.exe" /f

REG ADD %KEY%70 /V 2 /D "%WINDIR%\system32\defrg.exe" /f

REG ADD %KEY%90 /VE /D "Restarting Computer" /f

REG ADD %KEY%90 /V 1 /D "%WINDIR%\system32\restart.cmd" /f

runonce works fine. i use to use a js script for the defrag but it didnt have the GUI i wanted thus the reason for creating one in Autoit. If i have no success ill go back to my js version.

Link to comment
Share on other sites

Your missing a backslash in your cmd file. Notice the KEY Environmental Variable change.

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\

REG ADD %KEY% /V TITLE /D "Installing Applications" /f

REG ADD %KEY%02 /VE /D "BTS Driver Pack Finisher" /f
REG ADD %KEY%02 /V 1 /D "%SystemDrive%\DPsFnshr.exe" /f
REG ADD %KEY%02 /V 2 /D "reschangecon.exe -width=1024 -height=768 -depth=32" /f

REG ADD %KEY%15 /VE /D "McAfee VirusScan Enterprise 8.0" /f
REG ADD %KEY%15 /V 1 /D "%systemdrive%\install\VE8.0iPatch13\setup.exe /qb" /f
REG ADD %KEY%15 /V 2 /D "%systemdrive%\install\sdat4944.exe /silent" /f

REG ADD %KEY%25 /VE /D "Adobe Reader 8.0" /f
REG ADD %KEY%25 /V 1 /D "%systemdrive%\install\reader8.exe" /f

REG ADD %KEY%50 /VE /D "Macromedia Shockwave 10.0.1" /f
REG ADD %KEY%50 /V 1 /D "%systemdrive%\install\Shockwave10.exe" /f

REG ADD %KEY%60 /VE /D "Cleanup" /f
REG ADD %KEY%60 /V 1 /D "REGEDIT /s %WINDIR%\system32\regcleanup.reg" /f
REG ADD %KEY%60 /V 2 /D "%WINDIR%\system32\cleanup.cmd" /f

REG ADD %KEY%70 /VE /D "Defragmentation" /f
REG ADD %KEY%70 /V 1 /D "%WINDIR%\system32\defrg.exe" /f
REG ADD %KEY%70 /V 2 /D "%WINDIR%\system32\defrg.exe" /f

REG ADD %KEY%90 /VE /D "Restarting Computer" /f
REG ADD %KEY%90 /V 1 /D "%WINDIR%\system32\restart.cmd" /f
Link to comment
Share on other sites

You need to have a trailing backslash to create the numbers keys under the RunOnceEx key.

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\

Before in registry

RunOnceEx
RunOnceEx01
RunOnceEx02
RunOnceEx03

After in registry with change

RunOnceEx
- 01
- 02
- 03

Without the backslash, then keys were being created outside of the RunOnceEx key rather then inside the RunOnceEx key.

:)

Link to comment
Share on other sites

REG ADD %KEY%70 /VE /D "Defragmentation" /f

REG ADD %KEY%70 /V 1 /D "%WINDIR%\system32\defrg.exe" /f

REG ADD %KEY%70 /V 2 /D "%WINDIR%\system32\defrg.exe" /f

Miss spell defrg.exe it shoulbe defrag.exe also you are missing the drive to defrag.

REG ADD %KEY%70 /VE /D "Defragmentation" /f

REG ADD %KEY%70 /V 1 /D "%WINDIR%\system32\defrag.exe %SystemDrive%" /f

REG ADD %KEY%70 /V 2 /D "%WINDIR%\system32\defrag.exe %SystemDrive%" /f

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

MHZ,

its not Run("defrag.exe c: -f", "", @SW_HIDE) line which is a problem. the GUI before this part of the script runs dosent run itself. works fine in windows.

Danny35D,

im not running microsft defrag direct. ive got an autoit script callded defrg.exe which brings up a GUI for 6 seconds before it runs defrag.exe.

its still not working with the backslash added to the runonce.

Link to comment
Share on other sites

runwait is no good it pauses the GUI

Yes, and stops your next entry in RunOnceEx running if your script exits before defrag.exe finishes. You can hide your gui or delete it before the RunWait if you do not want to see the Gui anymore. But your script needs to run while defrag.exe does. Edited by MHz
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...