Sign in to follow this  
Followers 0
Nomadic

Very simple Autorun for CD

2 posts in this topic

Wrote quick autorun, can to someone it is required.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

If Not FileExists("autorun.inf") Then
    MsgBox(16,"Error!","File autorun.inf not found!")
    Exit
EndIf

$count = (UBound(IniReadSection("autorun.inf", "buttons"))-1)/2

If $count > 10 Then
    MsgBox(16,"Error!","Supports up to 10 buttons!")
    Exit
EndIf

If IsFloat($count) Then
    MsgBox(16,"Error!","Fractional number parameters of buttons!"&@CRLF&"Count = "&$count)
    Exit
EndIf

Dim $buttons[11] ; Maximum 10 buttons

$space = 60

$Form1 = GUICreate(IniRead("autorun.inf", "config", "Title", "Autorun"), 307, ($space*$count)+20, -1, -1)
For $i = 1 To $count
    $buttons[$i] = GUICtrlCreateButton(IniRead("autorun.inf", "buttons", "Button"&$i,""), 16, ($space*($i-1))+20, 275, 41)
Next

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
    For $i = 1 To $count
        If $nMsg = $buttons[$i] Then
            $path = IniRead("autorun.inf", "buttons", "Path"&$i,"")
            If FileExists($path) Then
                Run($path)
            Else
                MsgBox(16,"Error!","Path '"&$path&"' not found!",60)
            EndIf
            ExitLoop
        EndIf
    Next
WEnd

The maximum is supported to 10 buttons, it will be already ugly more...

Settings are stored in standard autorun.inf (additional sections):

[autorun]
Icon=AutoRun.exe
Open=AutoRun.exe
UseAutoPlay=1

[config]
Title=Autorun Demo

[buttons]
Button1=Demo #1
Path1=demo1\setup.exe
[...]
Button10=Demo #10
Path10=demo10\setup.exe
1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0