Update Front End

I've seen so many threads on how to update FE. And anyone who suggests using a bat file, uses COPY command to copy the new version.

I just wanted to say COPY command is dead. It's a very long time since Microsoft introduced ROBOCOPY.
ROBOCOPY is multi threaded, hence faster. Has logging capabilities, You can use it to keep backups by not using /mir. You can copy folder and file time stamps to the original. It has much more options, Etc etc.

And above all, it has a progress meter that shows copying (in this case updating) progress. At least the user faces a progressing percentage instead of an hourglass mouse icon.

2021-10-26_10-15-43.jpg
 
Robocopy does indeed have all of those benefits but it is still well over 20 years old and based on DOS.

I suggest using an API to do this.
Copying will be MUCH faster & you will get progress shown similar to that below (depending on your Windows version)

Capture.PNG
 

Attachments

I suggest using an API to do this.

I've never liked APIs. Mostly because I don't understand them and I can't write them. I don't feel comfortable copying and using something that I don't understand.
I leave it to pros & geniuses like you or others. I prefer to keep my limits and work with a bat that I can understand and modify to my needs.

I also assume you need to run the API from a strater. It's another thing I can't get used to. I think it's two step more than what's needed.
Launch starter. Launch your app. Close starter.

And since each step takes a little while, why should I go the longer route when there's a shorter one?

And I really don't find any privileges using a starter for updating FE rather than using a bat.
 
Last edited:
A 20 year old program sounds good to me. Thoroughly tested. Like Joel Spolsky says about old software- "It doesn’t acquire bugs just by sitting around on your hard drive."

That's an unusual use of the acronym "API". I thought it was short for "Application Programming Interface". Not quite sure what application is being programmed here. It's hard to describe a short routine of a few lines, to copy a file over, as an "application".
 
Like Joel Spolsky says about old software- "It doesn’t acquire bugs just by sitting around on your hard drive."

Unfortunately, Joel is incorrect. Old software acquires bugs by not being updated when the O/S is forced by circumstances to embrace new features that modify the meaning or even availability of certain options. That which stands still can be passed by. Particularly since at some point, MS drop-kicked the concept of backwards compatibility out into the trash heap. (And has done it again with Windows 11, which won't run on every machine.)
 
Keep in mind that we are copying ONE file and it is rarely a large one at that so I'm not sure you would even see a progress meter but thanks for reminding me.
 
Unfortunately, Joel is incorrect. Old software acquires bugs by not being updated when the O/S is forced by circumstances to embrace new features that modify the meaning or even availability of certain options. That which stands still can be passed by. Particularly since at some point, MS drop-kicked the concept of backwards compatibility out into the trash heap. (And has done it again with Windows 11, which won't run on every machine.)
Yes, you are absolutely correct. And to be honest, I quoted Joel Spolsky out of context, naughty me. Still I've found his writing on software development fascinating, including that article about Netscape's rewrite (this forum won't let me post hyperlinks).
 
Keep in mind that we are copying ONE file and it is rarely a large one at that so I'm not sure you would even see a progress meter but thanks for reminding me.
I do see it. The FE is a huge one and it's being updated from a domain controller to each client.
 
I've never liked APIs. Mostly because I don't understand them and I can't write them. I don't feel comfortable copying and using something that I don't understand.
I leave it to pros & geniuses like you or others. I prefer to keep my limits and work with a bat that I can understand and modify to my needs.

I also assume you need to run the API from a strater. It's another thing I can't get used to. I think it's two step more than what's needed.
Launch starter. Launch your app. Close starter.

And since each step takes a little while, why should I go the longer route when there's a shorter one?

And I really don't find any privileges using a starter for updating FE rather than using a bat.
All valid points but the advantages are significant.
1. Applying the API to your code is VERY simple. Basically its 'plug & play'
2. In my opinion, it looks better than using a command window. Users will be familiar with the Windows file copy dialog & progress bar
3. The progress bar still runs even if only one file is copied as it works on % of total file size copied to date (not the number of files copied)
4. File copying is VERY fast. Typically my application upgrade folder contains a number of files and in some cases can be 130 MB or more in total:

1640254072584.png


The API checks and only copies files which are newer (unless a forced update is used - in which case ALL files are copied).
Even if all files are downloaded, it takes just a few seconds
5. After updating files, the starter app closes and the main app is opened - both happen automatically

Here is a short (17 sec) unedited video of this being used in real time:

 
The FE is a huge one and it's being updated from a domain controller to each client.
The FE does not contain any data. But yes, there will occasionally be a large one. We ALWAYS have to use judgement in our decisions. The download is still only ever one file. It is not a bulk file transfer. One user double clicks on the shortcut and one file is downloaded and opened in response. It's not like you are sending 100 users new copies all at once.
 
The download is still only ever one file. It is not a bulk file transfer.

Not in my case. I have to copy a whole folder. The FE for sure, a set of icons, images, logos that are used in forms/reports, plus a handful set of excel files.
If I change the structure of a query, the pivot tables and graphs in several Excel files should be updated. Or if I add/change a logo in a report, the image should be downloaded to the client personal folder.
I can not run the risk of when a user tries to show a graph in a meeting, facing some errors or wrong results or a report can not be printed because the logo is different or doesn't exists.
 
As you saw from my screenshot, I also often copy an entire folder.
I store standard images like logos together with help files etc in a Common folder on the network
The additional files saved locally include 3 legacy DLLs for the occasional client still on very old versions, a version text file which is used for comparison before any files are downloaded. The subfolders contain template files for exporting items to Access or Excel files e.g. student/class reports.

Even so the major part of the download is the FE itself - over 110 MB but it used to be 130 MB at one time.
And no it doesn't contain any attachment fields - its just a huge FE database ... the SQL BE is currently around 2.2 GB
 
An API is still the best option , as long as the API is trusted and well documented.
 
Somehow we ended up down a rabbit hole. I'm talking about distributing a FE which is what the post is talking about and now we're into copying whole folders and distributing to every user at once. OK, there are better techniques for coping large numbers of files. I agree.

With an inhouse distribution, we almost never have to include .dll's or folders filled with other supporting files. We just periodically download the new copy of the FE, most of which are significantly smaller than Colin's, one user at a time.
 
An API is still the best option , as long as the API is trusted and well documented.
The "I" in "API" stands for "interface". An API isn't a program, it's an interface to a program or a computer. To what program are you suggesting an API is the best interface?
 
The link in post #56 relates to OneDrive.
It isn't what is needed for copying files on the same computer (or local network).
This is the code I use. It should work in both 32-bit & 64-bit
Copy into a standard module e.g. modCopyAPI

Rich (BB code):
Option Compare Database
Option Explicit

'API declarations - updated 12/03/2019

Private Type SHFILEOPSTRUCT
    #If VBA7 Then
        hWnd As LongPtr
    #Else
        hWnd As Long
    #End If
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Long
    
    #If VBA7 Then
        hNameMappings As LongPtr
    #Else
        hNameMappings As Long
    #End If
    
    lpszProgressTitle As String
End Type

'#####################################

#If VBA7 Then 'A2010 or later (32/64-bit)
    Private Declare PtrSafe Function SHFileOperation Lib "shell32.dll" _
    Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

#Else 'A2007 or earlier
    Private Declare Function SHFileOperation Lib "shell32.dll" _
    Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

#End If
'#####################################

Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FO_COPY = &H2

'#####################################

Public Function apiFileCopy(src As String, Dest As String, _
    Optional NoConfirm As Boolean = False) As Boolean
    
     'PARAMETERS: src: Source File (FullPath)
     'dest: Destination File (FullPath or directory)
     'NoConfirm (Optional): If set to true, no confirmation box
     'is displayed when overwriting existing files, and no
     'copy progress dialog box is displayed
    
     'Returns (True if Successful, false otherwise)
    
    Dim WinType_SFO As SHFILEOPSTRUCT
    Dim lRet As Long
    Dim lflags As Long
    
    lflags = FOF_ALLOWUNDO
    If NoConfirm Then lflags = lflags & FOF_NOCONFIRMATION
    
    With WinType_SFO
        .wFunc = FO_COPY
        .pFrom = src
        .pTo = Dest
        .fFlags = lflags
    End With
    
    lRet = SHFileOperation(WinType_SFO)
    apiFileCopy = (lRet = 0)
    
End Function

To run the code, use something like this:

Rich (BB code):
Sub TestCopy()

    Dim FromPath As String, ToPath As String
    
    'select a file or folder
   ' FromPath = "G:\Programs\MendipDataSystems\CommonFiles\UKPAF\Datafiles\Postcodes.accdb" 'source file to be copied
    FromPath = "G:\Programs\MendipDataSystems\CommonFiles\UKPAF\Datafiles\" 'source folder to be copied
    
    ToPath = "G:\MyFiles\ExampleDatabases\APIFileCopy\" 'destination folder
    
    Call apiFileCopy(FromPath, ToPath, True) 'set false to prevent the progress dialog being displayed - slightly faster
    
   ' MsgBox "Done"
    
End Sub

Example dialog (showing more details as option):
1640339220208.png
 

Attachments

OK, thanks.

I"m glad to hear that using the Windows copy command is using "an API", if that's a better way of doing things.
 
You are correct @isladogs


is one of several that can be used for file system API
I'm sorry but that link isn't relevant either. As it clearly states in the article, its allows Web apps to interact with local files which is nothing to do with the point of this thread
 

Users who are viewing this thread

Back
Top Bottom