Open DB via batch file (1 Viewer)

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
You need to set this one to allow a network location:
Code:
[HKEY_CURRENT_USER\Software\Microsoft\Office\17.0\Access\Security\Trusted Locations]
"AllowNetworkLocations"=dword:00000001

Here is what a local path looks like: for C:\Data
Code:
[HKEY_CURRENT_USER\Software\Microsoft\Office\17.0\Access\Security\Trusted Locations\Location0]
"Path"="C:\\Data\\"
"AllowSubfolders"=dword:00000001
"Description"=""
"Date"="5/30/2011 3:06 AM"

Here is what a UNC path looks like: for \\Pat-pc\pat-pc\data
Code:
[HKEY_CURRENT_USER\Software\Microsoft\Office\17.0\Access\Security\Trusted Locations\Location1]
"Path"="\\\\Pat-pc\\pat-pc\\Data\\"
"AllowSubfolders"=dword:00000001
"Description"=""
"Date"="06/28/11 2:06 PM"

This one you should have. Access installs it when it is installed:
Code:
[HKEY_CURRENT_USER\Software\Microsoft\Office\17.0\Access\Security\Trusted Locations\Location2]
"Path"="C:\\Program Files (x86)\\Microsoft Office\\Office17\\ACCWIZ\\"
"Description"="Access default location: Wizard Databases"

For the individual locations, you need to supply a unique name. Above you see Location0, Location1, Location2. Doesn't matter what the name is but it must be unique.

Type RegEdit in the search box for windows. It will open the registry. Drill down using the path structure above. 17.0 is my version of office. Yours might be different so change it as necesary. If you have multiple versions in the list, add the keys to the newest version.

To prevent having to constantly add new folders to trust, create a folder pretty high up in the hierarchy and trust it as well as its subfolders and always put your access databases somewhere in that hierarchy. So you need a minimum of three keys
1. to trust folders on the network
2. to trust a high level folder on your C:\ drive
3. to trust a high level folder on your server drive - you could use a mapped drive letter but I prefer to use UNC name for this.

If you name the text file with .rga as the extension, Windows will know it is a registry update and will run the update if you double click it. Sooooooooo be careful to not double click if you want to open it but not run it. Right click and choose Edit.

Your Network Administrator can (and should) do this for you. He can distribute to all the user computers. You just have to give him the keys you need to add.
Why would I get the following errors?

1644908754802.png
 

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
I'm going to post a different approach...

Instead of requiring VBA to hide your stuff, set it up to require VBA to continue into the DB. What you do is create a modal popup form that says you must enable scripts/content or whatever and set that as the form to load on startup in the settings. Also in settings, you turn off the navigation pane.

In the form's load event, you put code to close it and open the form you really want users to interact with.

When folks load the app, they get that form and nothing else until they allow scripts. Once scripts are allowed, the form goes away and they get the form they need. If they previously marked the file as trusted then scripts run as soon as it's opened meaning that form flashes quickly (usually too fast to even be noticed) and the proper form shows right away.

Alternatively, most of what I've released is in ACCDE format which cannot be open at all until the scripts are enabled, so this is rarely a problem.

And I just realized that the ACCDE approach is basically the same as the form approach but more solid and with Access doing the hard work for you.

Hi
The navigation pane will still be visible even before you enable the macros on the pop up screen, then only will the navigation pane be hidden
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:39
Joined
Oct 29, 2018
Messages
19,002
Hi
The navigation pane will still be visible even before you enable the macros on the pop up screen, then only will the navigation pane be hidden
The nav pane should be hidden if you use the options setting instead of code to hide it, no?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:39
Joined
Feb 19, 2002
Messages
36,387
Why would I get the following errors?
Did you change the paths to match YOUR paths. You need to look at YOUR registry to see what the number is for the version of Office AND, to run this file, you need to create a text file with the file type of .rga and run that.
 

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
Did you change the paths to match YOUR paths. You need to look at YOUR registry to see what the number is for the version of Office AND, to run this file, you need to create a text file with the file type of .rga and run that.
Hi,

Yes I changed the paths and change the version

I am in the dark here, trying to make sense of this, I have never worked with batch files before and not sure on the commands to use
I entered the commands as you have advised
I dont know the difference between regedit and batch commands and only going on what is advised
The samples you have provided has been entered into the batch file but I het the non recognized path

@ECHO OFF

::if not exist "%USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP"
md %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP
del %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP\DawSheet.accdb
copy "\\sjo2054\CAMO\DAW Sheet\Engineers\Daw Sheet.accdb" %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP\DawSheet.accdb

::)else(

::if exist "%USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP"
::del %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP\DawSheet.accdb
::copy "\\sjo2054\CAMO\DAW Sheet\Engineers\Daw Sheet.accdb" %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP\DawSheet.accdb
::)



set TrustedKey=[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations]
set TrustedKey=[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Eng_DAW_Sheet]
set TrustedKey=[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\EngDAWSHEETTEMP]
set TrustedKey=[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\DawSheet]

set dbpath="C:\\%USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\Eng_DAW_Sheet"
set dbpath="C:\\%USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP"
set dbpath="C:\\%USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\DawSheet"
set AllowSubfolders=dword:00000001
set Description="DAW Sheet"
set Date="5/30/2011 3:06 AM"


start %USERPROFILE%\AppData\Local\Temp\Eng_DAW_Sheet\EngDAWSHEETTEMP\DawSheet.accdb
 
Last edited:

JonXL

Member
Local time
Today, 17:39
Joined
Jul 9, 2021
Messages
65
Hi
The navigation pane will still be visible even before you enable the macros on the pop up screen, then only will the navigation pane be hidden
No. It won't. You can even try it to be sure.
 

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
And you cannot be bothered to search? :(

I actually have done quite a few searches
also looked at VBS script
I am not very familiar with this so I have tried a few ways
Also looking into copying the registry file but also not sure how to copy from a text file to the new computer

As you can see, the code has changed a few times since I started the discussion
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:39
Joined
Sep 21, 2011
Messages
10,581
I actually have done quite a few searches
also looked at VBS script
I am not very familiar with this so I have tried a few ways
Also looking into copying the registry file but also not sure how to copy from a text file to the new computer

As you can see, the code has changed a few times since I started the discussion
DO NOT COPY THE REGISTRY HIVE
Each is unique to the computer. You will come a cropper in short order if you do that.

I must admit I have never done it Pat's way, but then I do not have her experience.?
I have used regedit and the entries in a file. Those files always had a .reg extension and just running then added the entries to the registry.
I have not had the need to delete registry entries yet.

I have found a few still on my computer.
This one I called SaveToNetwork.reg and all it contains is
Code:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001

If you are not sure what you are doing, then stop. If you get this wrong, you might have to reinstall Windows, plus your other programs if it goes wrong :(
The registry is not for the faint hearted, believe me. :)

Here is a link from one of the links shown by the last link I posted.
If you do not understand this method, get someone who does.


That method will run from an actual batch file.
I myself would still prefer a reg or rga file as Pat has used, keeping the regedit command in their own file.

Again a quick search brings up how to run a reg file from a batch file.
 
Last edited:

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
DO NOT COPY THE REGISTRY HIVE
Each is unique to the computer. You will come a cropper in short order if you do that.

I must admit I have never done it Pat's way, but then I do not have her experience.?
I have used regedit and the entries in a file. Those files always had a .reg extension and just running then added the entries to the registry.
I have not had the need to delete registry entries yet.

I have found a few still on my computer.
This one I called SaveToNetwork.reg and all it contains is
Code:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001

If you are not sure what you are doing, then stop. If you get this wrong, you might have to reinstall Windows, plus your other programs if it goes wrong :(
The registry is not for the faint hearted, believe me. :)

Here is a link from one of the links shown by the last link I posted.
If you do not understand this method, get someone who does.


That method will run from an actual batch file.
I myself would still prefer a reg or rga file as Pat has used, keeping the regedit command in their own file.

Again a quick search brings up how to run a reg file from a batch file.
I realized my error
My batch file is a .bat
The registry file is a reg editor file
As you mentioned, I was giving the incorrect commands and did not understand why you stated that

I will have a look at the link you sent
Much appreciated
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:39
Joined
Feb 19, 2002
Messages
36,387
The code I posted was NOT for a batch file. If you want to run it automatically, the file extension is not .bat. It needs to be the one associated with the registry.

Normally, YOU would not be running this file. You would give the Registry keys (probably in a .txt file for safety) to your IT support person and he would use Active directory to push the keys to all the valid users.
 

Gismo

Registered User.
Local time
Tomorrow, 01:39
Joined
Jun 12, 2017
Messages
1,086
Hi
Just to confirm, if a location is trusted, I will net get the enable macro warning, correct?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:39
Joined
Feb 19, 2002
Messages
36,387
I'm not sure. I don't have the new version of windows/office yet with the "enhanced" security.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:39
Joined
Oct 29, 2018
Messages
19,002
Hi
Just to confirm, if a location is trusted, I will net get the enable macro warning, correct?
I'd say not necessarily. Typically, on a normal computer, that would be the case. But, if you're in a corporate environment with an IT department, they could have implemented a group policy where macros are not automatically enabled, and trusted locations may not have any effect on them. Just give it a try and find out for yourself. Let us know how it goes.
 

Users who are viewing this thread

Top Bottom