Jump to content

FileInstall Issues


Recommended Posts

I am using this as an auto updater for a program. I had a similar thread open but it received no response and I have since changed my tactic of how to address my issue. I have a Program called FieldOpsHelperWebpageBeta.exe. I have a separate executable to run that program. The intent is that anytime the Runner program is called, it re-installs the Field program and then runs it. This ensures a user always has the newest version. Maybe this isn't the best way to go about this, but it should work. The issue I am running into is that once the Runner program runs and installs the Field program, it wont install any new versions. To get a new version I have to recompile the Runner program and then run it again. I don't have to make any changes to the Runner program, just compile and run and suddenly it works. I can only assume there is some kind of cache that is cleared upon compile? This doesn't make much sense to me.

Code of the Runner program below. Note that I tried playing around some with FileSetAttrib, ultimately I want the Field program hidden. I was also playing around with Sleep() to see if it would help. Additionally I tried both FileDelete and FileMove with override flag on. Lastly, in FileInstall I didn't list the actual directory path because it contains company sensitive info.

 

FileInstall(some directory & "FieldOpsHelperWebpageBeta.exe", @ScriptDir & "\update.exe")
FileDelete(@ScriptDir & "\FieldOpsHelperWebpageBeta.exe")
FileMove(@ScriptDir & "\update.exe",@ScriptDir & "\FieldOpsHelperWebpageBeta.exe", 1)
FileSetAttrib(@ScriptDir & "\FieldOpsHelperWebpageBeta.exe", "-H+N")
FileSetAttrib(@ScriptDir & "\FieldOpsHelperWebpageBeta.exe", "+H")
Sleep(3000)
ShellExecute("FieldOpsHelperWebpageBeta.exe", "runas")

 

Link to comment
Share on other sites

I think you're misunderstanding the way FileInstall works... FileInstall only copies the 'FieldOpsHelperWebpageBeta.exe' file into the wrapper when it is compiled. Every time you run this compiled script, it is just extracting whatever you compiled in, back out, and deleting the old copy. In other words, you'll only ever get out the version you compile with.

What you're looking to do is have some way to fetch the latest version before running. You can do this with a personal/company website or a drive that everyone will have access to and possibly more creative ways that I don't know of. FileInstall won't work as an auto-update feature though :( That would be amazing though :D

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Hmmm, I think I understand what your saying. Basically FileInstall isn't actually accessing the current file everytime the Runner program is called. It just copies and saves whatever the file was at compile time of the Runner. This doesn't seem so great in the end. I'm puzzled as to why but thats beyond me.

My question then would be if anyone else does know of other ways to do this? This might be too convoluted but if there isn't a function like FileInstall but that works how I thought it did, are there commands to compile a program?

Hypothetical: Have a 3rd program (I know already getting ridiculous) that had a Shell function to compile the Runner program then a ShellExecute to run the Runner. This way FileInstall in the Runner would be compiled and updated everytime to then pull the current version of the intended exe i.e. FieldOpsHelper in this case.

I hope that makes sense as a hypothetical lol.

Link to comment
Share on other sites

How are you distributing your updated application? If it is on a shared network drive, then just point your AutoIt code to the shared location (assuming a common or configurable mount point for the users) and whenever you update the application AutoIt will run the latest version. If your AutoIt code is distributed off your network then you can use InetGet in your AutoIt code to automatically download it from a location that you host.

FileInstall would typically be used if your AutoIt code required supporting files, e.g. .dll or document templates. This allows you to compile the supporting files within your AutoIt .exe for ease of distribution. Any updates to the supporting files will require coding in AutoIt - to know when and how to get the files.

 

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Link to comment
Share on other sites

So my file is on a shared network drive. The issue I run into is if I just point the Runner at the exe on the drive, I can't update the file while someone is using it. Exe won't compile while in use. That's the part I am trying to get around. Maybe there's another way to do this. I've never tried to have an updatable program like this before.

Link to comment
Share on other sites

Like this...

If @ScriptDir = @DesktopDir Then
    ; "Do nothing, keep going"
Else
    FileCopy(@ScriptFullPath, @DesktopDir & '\' & @ScriptName)
    Run(@DesktopDir & '\' & @ScriptName)
    Exit
EndIf

If the script isn't on the desktop, copy to the desktop, and run it. You could even have a check at the end of your script (if you were feeling fancy) to automatically delete itself if it was on the desktop.

Edit: Would probably be better to use @AppDataDir instead of @DesktopDir so the user never sees it

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

I tested and this works great. Thank you so much. Side note, for some reason the "Date/Time" doesn't seem to update correctly on the copied file. This through me off at first, but after testing it does seem to actually update the program itself.

Edited by StuckUser
Link to comment
Share on other sites

I've seen this before. Sometimes you have to refresh (F5) the file explorer because it doesn't notice all of the changes made. Other times, you can view the file properties window and see changes in details only. Glad to hear it works now! :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Hello,

this is how I do "local-copy-updates" from Network Shares to the PCs.

The Benefit is, that the update is done *ALWAYS* when a *DIFFERENT* Version is dropped at the Server (no matter whether the Version number increases or decreases)

And as the program is started from local disk, the copy at the Server is not locked (so remains replacable).

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=\\file01\install\Autoit\MyIcon.ico
#AutoIt3Wrapper_Outfile=\\file01\install\Autoit\AutoUpdate-Example.exe
#AutoIt3Wrapper_Res_Fileversion=1.0.0.5
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_SaveSource=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Misc.au3>

$Title = StringTrimRight(@ScriptName, 4) & ", v" & FileGetVersion(@ScriptFullPath)

$dom = "AD-Domain-Name"
$ADlogon = (@LogonDomain = $dom)
ToolTip("Lokally logged on as: " & @LogonDomain & "\" & @UserName & @CRLF & "AD-Logon = " & $ADlogon, 100, 100)
$User = $dom & "\" & @UserName
$SrvAutoitDir = "\\file01\install\Autoit"

$Desc = "File to do what it is supposed to do ..."
$LocalCopy = "C:\install\" & @ScriptName
$Lnk = @DesktopDir & "\Some nice Name for the Link.lnk"
$AllUsersLnk = @DesktopCommonDir & "\Some nice Name for the Link.lnk"
$SrvStarter = $SrvAutoitDir &"\" & @ScriptName

$Icon = "C:\install\MyIcon.ico"
DirCreate("C:\install")
FileInstall("\\file01\install\Autoit\MyIcon.ico", $Icon, 1)


If @Compiled Then
    Opt("trayicondebug", 1)
    #Region check if running from local disk or network share
    $DoLocalUpdate = "CopyOverToLocalCopyWithWaiting"

    If $cmdline[0] = 1 And $cmdline[1] = $DoLocalUpdate Then
        ToolTip("Auto-Updating local copy, waiting 3 seconds for program termination.", 300, 300)
        Sleep(3000)
        ToolTip("")
    EndIf
    If DriveGetType(@ScriptFullPath) = "Network" Then
        MsgBox(0, "Info", "network recognized", 3)
        ; You might check for other instances of the local EXE, that were started before, as this is a constraint for overwriting the local copy.
        FileCopy(@ScriptFullPath, $LocalCopy, 1 + 8)
        DesktopLnk()
        ; your could also start the newly copied local EXE file before doing the exit in the next line
        Exit
    Else
        ToolTip("Program started from local disk")
        $Title &= " -local"
        If FileExists($SrvStarter) Then
            ToolTip("Server - Original file found")
            $SrvVer = FileGetVersion($SrvStarter)
            If _VersionCompare(FileGetVersion(@ScriptFullPath), $SrvVer) Then ; different version on the server found
                MsgBox(0, "Version number at Network Share is different!"," Server = " & $SrvVer & @CRLF & "This file = " & FileGetVersion(@ScriptFullPath) & @CRLF & @ScriptFullPath, 5)
                ToolTip("")
                ShellExecute($SrvStarter, $DoLocalUpdate, $SrvAutoitDir) ; call the copy on the server with the option to do the update to the local copy
                Exit
            EndIf
        Else
            ClipPut($SrvStarter)
            MsgBox(48,"Server - Original file *NOT* found!","The original EXE file on the server cannot be found.",5)
        EndIf
    EndIf
    #EndRegion
Else
    Opt("trayautopause", 0)
EndIf

Sleep(200)
ToolTip("")



Func DesktopLnk()
    ; If FileExists($AllUsersLnk) Then FileDelete($Lnk)
    $result = FileCreateShortcut($LocalCopy, $Lnk, "", "", $Desc & " v" & FileGetVersion($LocalCopy), $Icon)
    If $result Then
        MsgBox(64, "Desktop link created for v" & FileGetVersion($LocalCopy), "A Desktop link was created pointing to '" & @ScriptName& "'." & @CRLF & _
        "Local copy: " & $LocalCopy & @CRLF & _
        "Server    : " & $SrvStarter)
    Else
        MsgBox(48, "Failed to create Desktop link", "Could *NOT* create a Desktop link pointing to '" & @ScriptName& "'." & @CRLF & @ScriptFullPath)
    EndIf
EndFunc   ;==>DesktopLnk

Rudi.

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

Link to comment
Share on other sites

rudi, thx for that info. your code is quite a bit more complex. i will keep it in mind for the future. For now, the file I have is small and the few lines of code listed above from seadoggie work fine to just force the file to install every time.

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...