Access 2007 Trusted Location

Sula Dunklin

New member
Local time
Yesterday, 22:53
Joined
Oct 3, 2008
Messages
6
Good afternoon. I created a software using Access2000, converted it to Access 2007, packaged it as an executable with Access 2007 Runtime. The program has an auto executable that runs a macro upon startup. Microsoft 2007 automatically blocks macros disabling their functionality unless trusted. The error code is 2950. The problem is that if the user doesn't have Access 2007 on their computer, they can't trust the database location. I used the sample code below given to create a script to automatically trust the file, replacing the path with the location that my software is installed.
The problem is that it didn't work. The error remains and when I looked in the registry file, the sequence was dropped after the Access connectivity engine folder. So the trusted location was never registered.
Does anyone have any suggestions? Or have a totally confused you.
Thanks for any help.


Access 2007 FAQ




Using Access 2007 Runtime, how can I create a Trusted Location if there's no UI to create it?

You'll need to create a script or install routine that manually creates the necessary registry keys.

For example, setting these keys....

[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0]
AllowSubFolders (REG_DWORD) = 1
Path (REG_SZ) "C:\AccessJunkiesRule"
...results in this:

FAQ_33Screenshot.jpg


 
Currently messing about with the '07 version myself. Haven't had a chance to test but one of the notes I collected in my research was ...

Note When you specify a registry key to be added to the All Users root, you should preface the key with Software\. If you don't do this, then a user may receive an error message when installing your application.

Not sure if that helps or not ...

-dK
 
I will try it again, but I have used "software" in the registry set up before packaging. I only tried the script because it was given as a fix. The sequence may be wrong if that matters.
Thanks for your prompt response.:)
 
Thanks dk. It seems that many are having similar problems although for different reasons. I'm going to try a couple of tips from the forum and see what I come up with. I know that my issue is because of the macro that I have in place, but it is not a macro that I want to give up. When I remove the macro, the program works fine without needing to be trusted. The new security in Microsoft Access 2007 auto disables all macros unless trusted.
I'm beginning to wonder if trusted location option was designed for the full version of Access 2007. If my customers are having to take too many steps to run a program they are likely to become impatient. I am able to package and deploy using Access 2000 which is how the program was originally developed, except that there are some features that 07 have that I like. All in all it doesn't change the functionality, but eventually I would like to launch in 07.
 
I know you can make a digitally signed certificate and bundle that in with the package. Like I said, I've prepared a package just haven't gotten to install it on another machine for testing.

-dK
 
The only problem I found with creating the digitally signed certificate which I've done is that you are unable to make the file a accde which add more security to it. The digitally signed certificate is save as a .accdc.
 
Here is this also ... Bob Larson points out to another link in this thread ...

http://www.access-programmers.co.uk/forums/archive/index.php/t-136411.html


-dK

Thanks for this post - this solves my problem.

We're using a frontend on a network share, I've added that share as a Trusted Location and it's working now.

Unfortunately there are quite a few users who have already "enabled all macro content" in the Trust Center as a workaround for the constant security messages, but hey ho.

I'm intrigued to know if there's a simple script I can create to add the network location into the users' "all users" registry setting to set the trusted network location "automatically", will have a look into it now. :)
 
Additionally, the Trusted Location means we can still have our accde file locked down further by renaming to accdr, so it runs using runtime and thereby prevents any changes to query design etc etc.
 
I'm intrigued to know if there's a simple script I can create to add the network location into the users' "all users" registry setting to set the trusted network location "automatically", will have a look into it now. :)

If anyone's interested in this, I just wrote a very simple little C# console app which registers the trusted location automatically when run. Obviously you'd need to update the UNC path to suit your needs. And I know hard-coding the value isn't ideal, but that's all i need right now.

Basically it opens the registry, checks for a Trusted Location (Current User settings only), and creates it if it doesn't already exist...

Most likely it's overkill for a lot of people, but for us it's perfect as we run all our small Access dbs from a centralised location on the network, so this is a simple "run once" exe to add that location as Trusted.

using System;
using System.Security.Permissions;
using Microsoft.Win32;

[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify = "HKEY_CURRENT_USER")]

namespace RegisterTrustedLocation
{
class Program
{
static void Main()
{
try
{
// Set UNC Path for new Trusted Location
string uncpath = "\\\\SERVER\\VOLUME\\SUBVOL\\DATABASES\\";

// Open Trusted Locations registry key
RegistryKey NewTrustedLocation = Registry.CurrentUser;
NewTrustedLocation = NewTrustedLocation.OpenSubKey("Software\\Microsoft\\Office\\12.0\\Access\\Security\\Trusted Locations\\", true);

// Check if trusted location already exists
string[] arrexistinglocations = NewTrustedLocation.GetSubKeyNames();
foreach (string existinglocation in arrexistinglocations)
{
using (RegistryKey subkey = NewTrustedLocation.OpenSubKey(existinglocation))
{
string[] locationdetails = subkey.GetValueNames();
foreach (string name in locationdetails)
{
if (name == "Path")
{
string existingpath = (string)subkey.GetValue(name);
if (existingpath == uncpath)
{
return; // Path exists therefore exit (to avoid creating duplicates)
}
}
}
}
}

// If we get this far, trusted location does not exist, therefore go ahead and create it
int i = (NewTrustedLocation.SubKeyCount + 1); // Get count of currently trusted locations (subkeys) and add 1
string rootpathname = "Location";
rootpathname = rootpathname + i;
NewTrustedLocation = NewTrustedLocation.CreateSubKey(rootpathname);

using (NewTrustedLocation)
{
NewTrustedLocation.SetValue("AllowSubfolders", 1);
NewTrustedLocation.SetValue("Date", DateTime.Now);
NewTrustedLocation.SetValue("Description", "");
NewTrustedLocation.SetValue("Path", uncpath);
}
}

catch
{
}

}
}
}
 
Last edited:

Users who are viewing this thread

Back
Top Bottom