Jump to content

Recommended Posts

Posted (edited)

hey, I was wondering if it is possible to store a .exe file inside your reference section of your autoit program?

I was thinking of like making a seperate program that would autoupdate my main program but use as a seperate program that is stored inside the main program without acually having to put that extra coding inside the main, as since updating it is going to delete the main program and replace with the updated one.

Edit: Reference or Resource.

Edited by KurogamineNox
Posted (edited)

Hey Kuro, I don't think it's possible to store a .exe file inside your reference section or even to try... I don't know how that will.. be

Instead, build yourself a second .exe that will receive command lines ("$CmdLine[0], $CmdLine[1], $CmdLine[2], ..." see help file). This should be your "ControlApps.exe". In that, you could code a reboot function, update function based on the cmdline received.

Ex: (don't copy-paste, its an example)

1. Application#1 : Send to "ControlApps.exe" what you want to do reboot, update, ... whatever

Run("ControlApps.exe", "update", "param2"[, "param3"])

Exit

2. "ControlApps.exe"

Get the command lines sent by Application#1

Add conditions

>If "update" = get fileversion from database or ini file or GetFileVersion(@Scriptname="Application#1"), do what you have to do

If Application#1 version < database Application#1 version, FileDelete(Application#1) and replace it with your new and updated Application#1

Run("Application#1")

Exit

>If "reboot" = Run("Application#1")

Exit

In a few lines, your done.

You absolutly need a second .exe cause the first one died, so...

This is the solution I use for my updates and reboots.

Hope it helps!

Edited by M a k a v e l !

[font="Lucida Sans Unicode"]M a k. a v e L ![/font]

Posted

Hi.

Not sure, if I get correctly, what you want: If you just want to make a program to autoupdate it's local copy from a central copy, then store the information of the cental location either within the program code itself, or, more flexible, store it in an INI file.

------------- MyProg.ini -----------------
[update]
CheckNewVersion=\\server\share\path\path\MyProg.exe
------------------------------------------

Then check within the program, if the central one is newer:

$Compare = IniRead(StringTrimRight(@ScriptName, 3) & "ini", "CheckNewVersion", "Failure")

;Check for update call.
If $cmdline[0] = 2 And $cmdline[1] = "-update" Then ; maybe check also, that -> DriveGetType($cmdline[2]="Fixed", and write rights
    $EmergencyExit = 0
    While 1
        If FileCopy(@ScriptFullPath, $cmdline[2], 1) Then ExitLoop ; 1 = overwrite
        Sleep(1000) ; wait 1 second for the local copy to terminate, so that it can be overwritten.
        $EmergencyExit += 1 ;increment 1
        If $EmergencyExit > 10 Then
            ; doesn't work: handle error (e.g. no local write rights...
            ExitLoop
        EndIf
    WEnd
    Run($cmdline[2]) ; start the local copy again.
    Exit
EndIf

If Not FileExists($Compare) Then ; check, that the file exists...
    ; handle error situation
Else
    $LocalVersion = FileGetVersion(@ScriptFullPath)
    $UpdateVersion = FileGetVersion($Compare)
    If _VersionCompare($LocalVersion, $UpdateVersion) < 0 Then
        Run($Compare & " -update " & @ScriptFullPath)
        Exit
    EndIf
EndIf

this is simplified from another script and not tested, just as a start.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted

Alright Ill see what I can do, though my main thought was like it keeps my update.exe inside the main program inside like the resources section then when I want it to update I guess copy the update.exe from resource and paste it inside the main programs installed directory. Then run it and update the main program then delete itself.

Reason because I thought it would be easier to just add coding in a separate program rather than the main program itself, that way I could like add some special things to the update.exe, but ill see what I can do. Thanks.

Posted (edited)

It is in fact

easier to just add coding in a separate program rather than the main program itself

... depending on what you need to do Edited by M a k a v e l !

[font="Lucida Sans Unicode"]M a k. a v e L ![/font]

  • 2 weeks later...
Posted (edited)

Hello!

I'm interested and I can update my browser ;)

My source...

#NoTrayIcon
#Include <INet.au3>
#Include <String.au3>
#include <GUIConstantsEx.au3>

Global $oIE = ObjCreate("Shell.Explorer.2")
Global $ini = @ScriptDir & "\Browser Log.ini"
Global $_Next
Global $read_height = IniRead($ini, "Display", "Height", "")
Global $read_width = IniRead($ini, "Display", "Width", "")
Global $read_homepage = IniRead($ini, "Settings", "Homepage", "")
Global $read_starthomepage = IniRead($ini, "Settings", "StartHomepage", "")

If $read_height = "" Then
    IniWrite($ini, "Display", "Height", "600")
    IniWrite($ini, "Display", "Width", "800")
    $read_height = 600
    $read_width = 800
EndIf

If $read_starthomepage = "" Then
    $read_starthomepage = "1"
    $read_homepage = "http://www.domain.com"
EndIf

$iniread = IniRead($ini, "URL", "LAST URL", " ")
If $read_starthomepage = "0" Then $read_homepage = $iniread

$gui_main = GUICreate("", $read_width, $read_height + 20, -1, -1, 0x04000000 + 0x00CF0000)
$file_menu = GUICtrlCreateMenu("File")
$fm_open = GUICtrlCreateMenuItem("Open", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_print = GUICtrlCreateMenuItem("Print", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_savas = GUICtrlCreateMenuItem("Save As", $file_menu)
$fm_SaveSource = GUICtrlCreateMenuItem("Save Source", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_exit = GUICtrlCreateMenuItem("Exit", $file_menu)

$fav_menu = GUICtrlCreateMenu("Favorites")
$fav1 = GUICtrlCreateMenuItem("First favorit", $fav_menu)
$fav2 = GUICtrlCreateMenuItem("Second favorit", $fav_menu)

$tool_menu = GUICtrlCreateMenu("Recommendations")
$tm_recommendation = GUICtrlCreateMenuItem("Recommendation", $tool_menu)

$about_menu = GUICtrlCreateMenu("About")
$am_about = GUICtrlCreateMenuItem("About", $about_menu)

$gui_iewindow = GUICtrlCreateObj($oIE, 0, 0, $read_width, $read_height - 15)
GUICtrlSetResizing($gui_iewindow, 0x0001)
$status_bar = GUICtrlCreateLabel("Loading: " & $read_homepage & "...", 0, 584, $read_width, $read_height, BitOR(11, 0x1000))
GUISetState()

AnimateTitle($gui_main, "Browser - Created by Justin Reno/Modified by LordJugag", 100)
$oIE.Navigate ($read_homepage)

While 1
    WinSetTitle($gui_main, "", "Browser - Created by Justin Reno/Modified by LordJugag - " & $oIE.locationURL ())
    
    If $oIE.Busy () Then
        $url = $oIE.LocationURL ()
        _StatusChange("Loading: " & $url & "...")
    Else
        _StatusChange("Done.")
    EndIf

    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case - 3
            $update = $oIE.LocationURL ()
            IniWrite($ini, "URL", "LAST URL", $update)
            Exit
            ;File Menu
        Case $fm_open
            Local $file = FileOpenDialog("Browser : Select file", @ScriptDir, "All Files (*.*)")
            If @error <> 1 Then
                _StatusChange("Loading: " & $file & "...")
                $oIE.Navigate ($file)
            EndIf
        Case $fm_print
            $oIE.document.parentwindow.Print ()
        Case $fm_savas
            $oIE.document.execCommand ("SaveAs")
        Case $fm_SaveSource
            $IE = _INetGetSource("" & $update & "")
            FileWrite(@DesktopDir & "\websource.html", $IE)
            MsgBox(0, "Browser", "Saved to desktop as websource.html")
        Case $fm_exit
            $update = $oIE.LocationURL ()
            IniWrite($ini, "URL", "LAST URL", $update)
            Exit
            ;Favorites Menu
        Case $fav1
            $oIE.Navigate ("http://first.domain.com")
        Case $fav2
            $oIE.Navigate ("http://second.domain.com")
            ;Recruiter Menu
        Case $tm_recruit
            _Recruiter()
            ;About Menu
        Case $am_about
            MsgBox ( 0, 'About', 'Browser - Created by Justin Reno/Modified by LordJugag' )
    EndSwitch
WEnd

Func _StatusChange($message)
    GUICtrlSetData($status_bar, $message)
EndFunc   ;==>_StatusChange

Func _Recommendations()
    $_Next = $_Next + 1
    If $_Next > 9 Then 
        GUICtrlSetState ( $tm_recommendation, $GUI_DISABLE )
        MsgBox ( 0, 'Recommendations', 'Database is empty' )
    EndIf
    ConsoleWrite ( "$_Next : " & $_Next & @Crlf )
    Switch $_Next
        Case 1
            $oIE.Navigate ("link1")
        Case 2
            $oIE.Navigate ("link2")
        Case 3
            $oIE.Navigate ("link3")
        Case 4
            $oIE.Navigate ("link4")
        Case 5
            $oIE.Navigate ("link5")
        Case 6
            $oIE.Navigate ("link6")
        Case 7
            $oIE.Navigate ("link7")
        Case 8
            $oIE.Navigate ("link8")
        Case 9
            $oIE.Navigate ("link9")
    EndSwitch
EndFunc   ;==>_Recommendations

Func AnimateTitle($hGUI, $sTitle, $iBuf)
    $sTitle = StringSplit($sTitle, "")
    For $i = $iBuf To 0 Step - 1
        WinSetTitle($hGUI, "", _StringRepeat(" ", $i) & $sTitle[1])
    Next
    Local $s
    For $i = 1 To $sTitle[0]
        $s &= $sTitle[$i]
        WinSetTitle($hGUI, "", $s)
        Sleep(5)
    Next
EndFunc   ;==>AnimateTitle

I want to start the browser to make update the list by recommendations from a server... how Do I? Can anyone help me?

Edited by LordJugag
Posted

FileInstall allow you to store a file to your program.

But after that it will be extracted, you can use Run to run it.

Another way is put it as a function. It's nothing different when they are all compiled into binary file.

Posted (edited)

saw it. But I believe the doesn't run :|

Can you elaborate what do you mean by update the list by recommendation?

receive data

update list using guictrlsetdata, etc...

Edited by trung0407
Posted

I want when you start the browser to make updates taking a file from server. File containing a list of recommended links. Browser to read list from file to recommend when click on button "Recommendation". I was clear enough?

Posted

Thanks for guidance...

I have these questions:

How to combine two instructions?

$oIE.Navigate ("http://www.domain1.com")
with

$iniread = IniRead($ini, "RECCOMENDATION", "DOMAIN_1", "")

I want to take the link from Browser.ini ;)

Example from Browser.ini

[URL]
LAST URL=http://www.autoitscript.com
[DISPLAY]
HEIGHT=600
WIDTH=800
[RECCOMENDATION]
DOMAIN_1=http://www.domain1.com
DOMAIN_2=http://www.domain2.com
DOMAIN_3=http://www.domain3.com
DOMAIN_4=http://www.domain4.com
DOMAIN_5=http://www.domain5.com
Posted (edited)

I'm stupid ... thank you :)

Another small issue...

Case $tm_recommendation
            _Recommendation()
            FileDelete("\Browser.ini")
            InetGet("http://www.domain.com/Browser.ini", @TempDir & "\Browser.ini", 1, 0)

... is ok ? We need to do something? ;)

Edited by LordJugag

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
×
×
  • Create New...