Batch file to copy Master copy to all users (1 Viewer)

Kayleigh

Member
Local time
Today, 09:15
Joined
Sep 24, 2020
Messages
706
Hi,
I'm attempting to distribute my system to all users on the LAN. I was advised to write a batch file which copies the Master copy from a shared location onto the user's appdata/local folder and a shortcut to their desktop (including a specific icon for the shortcut).
Any pointers or sample code to start me off please?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 19, 2002
Messages
42,970
I use a very simple batch file that doesn't include error trapping. The two errors that might happen can be ignored. The script starts with making the directory. This allows new users to start without doing anything. If the directory already exists, the command fails and moves to the next line. The code deletes the old file. Again, if there is no existing file, the command fails and moves to the next line. Conceivably the third line could fail if for some reason the FE went missing but it would move on and the last line would fail because there was no database found. So, you could trap that error if you want.

md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" c:\DwgLog
c:\DwgLog\DrawingLog.accdb
 

Kayleigh

Member
Local time
Today, 09:15
Joined
Sep 24, 2020
Messages
706
@arnelgp - I use a similar autoupdater to update users' front end whenever the master is updated. However I am struggling with doing the initial install on all users.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 19, 2002
Messages
42,970
That is why I wrote the batch file the way I did. I thought that would be clear in my explanation of the error potential which I chose to ignore specifically so that the same batch file could be used for both new and existing users.

I leave the .bat file on the server in the same folder as the master FE. That makes it easy for me to change should I want to. To get a new user onboard, send the user a shortcut to the batch file on the server and have them save it on their desktop.
 

Cotswold

Active member
Local time
Today, 09:15
Joined
Dec 31, 2020
Messages
520
If you are issuing a batch file, I suggest that you download a Batch To Exe program.

There are a few about and some are free. It takes your batch file and converts it into an executable.
The advantage is that your users cannot read or amend the instructions. Sometimes you don't want
a user to know where all of the files in your application are. Or you simply want to prevent tampering
by some enthusiastic amateur.

Clearly the last thing you want is some bright spark amending paths, which may result in problems for you later.
 

Cronk

Registered User.
Local time
Today, 20:15
Joined
Jul 4, 2013
Messages
2,770
@Pat, is that batch code off the top of your head? How do you delete a sub folder immediately after creating the parent?

Code:
md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 19, 2002
Messages
42,970
is that batch code off the top of your head? How do you delete a sub folder immediately after creating the parent?
The code I posted is direct from the .bat file for an installed application. It does NOT delete folders. It deletes the existing copy of the database. I don't understand why you want to delete subfolders in this install process.

If you have a multi-tiered local folder to hold the FE, You could create each level in the .bat file but you have to do it one level at a time so if there are three levels, you would have three MD commands. But I don't know why you want to delete subfolders. You could using the RD command.
 

Cronk

Registered User.
Local time
Today, 20:15
Joined
Jul 4, 2013
Messages
2,770
Sorry I should have asked why do you delete a file in a new folder that you have just created. If you created a
new folder, I can't understand how there can be a file in that folder to delete?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 19, 2002
Messages
42,970
Sorry I should have asked why do you delete a file in a new folder that you have just created. If you created a
new folder, I can't understand how there can be a file in that folder to delete?
Because, the directory isn't always not there. The command to create the directory caters to new users. If the directory already exists, the error is ignored. Deleting the FE file caters to existing users. If the file does not exist, the error is ignored. I could omit the file delete but then I would actually have to trap the error raised by downloading FileA on top of an existing FileA. I went with the simplest sequence possible. The last two instructions download the new copy of the FE and open it.

Soooooooooooo - you can have one script that works in all cases or you can have two scripts and figure out which you want to run. That is why I didn't bother with error trapping. I don't care if either of the first two raise errors. They will always, at some point in time raise an error. As long as the script continues to run despite the error, all is well.
 

Users who are viewing this thread

Top Bottom