[AccessD] Deployment Advice

Steve Schapel steve at datamanagementsolutions.biz
Sat Sep 21 18:52:42 CDT 2013


That's cool, Stuart.

I use the AddPath.exe which I obtained from
http://www.accessribbon.de/en/?Trust_Center:Trusted_Locations

Regards
Steve

-----Original Message----- 
From: Stuart McLachlan
Sent: Sunday, September 22, 2013 10:17 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Deployment Advice

On 22 Sep 2013 at 9:38, Steve Schapel wrote:

>
> - You need to set up the folder on the production machine as a "trusted
> location", which you can't do via the Runtime.  There are a couple of
> utilities around that you can use to do this... the one I use is just a
> little exe file that you put in the application folder and run it once... 
> I
> can track down where I got it from and let you know if you need.
>
> Regards
> Steve
>

I do it with a mdb/accdc.

A simple database with  one module and an Autoexe macro which calls a 
function Startup().
It does require you to allow execution manually when you open it.  (One of 
these days I will
get around to making it a small .exe with PowerBasic)

Here's the module (not usre where I found the function - on the internet 
somewhere):

Option Compare Database
Option Explicit

Function Startup()
AddTrustedLocation
DoCmd.Quit
End Function

Public Function AddTrustedLocation()
On Error GoTo err_proc
'WARNING:  THIS CODE MODIFIES THE REGISTRY
'sets registry key for 'trusted location'

  Dim intLocns As Integer
  Dim i As Integer
  Dim intNotUsed As Integer
  Dim strLnKey As String
  Dim reg As Object
  Dim strPath As String
  Dim strTitle As String
  Dim strTrustedLocations As String
  strTitle = "Add Trusted Location"
  Set reg = CreateObject("wscript.shell")
  strPath = CurrentProject.Path
  strTrustedLocations = "HKEY_CURRENT_USER\Software\Microsoft\Office\" &
Format(Application.Version, "##,##0.0") & _
             "\Access\Security\Trusted Locations"
  'Specify the registry trusted locations path for the version of Access 
used
  strLnKey = strTrustedLocations & "\Location"

On Error GoTo err_proc0
  'find top of range of trusted locations references in registry
  For i = 999 To 0 Step -1
      reg.RegRead strLnKey & i & "\Path"
      GoTo chckRegPths        'Reg.RegRead successful, location exists > 
check for path in all
locations 0 - i.
checknext:
  Next
  MsgBox "Unexpected Error - No Registry Locations found", vbExclamation
  GoTo exit_proc


chckRegPths:
'Check if Currentdb path already a trusted location
'reg.RegRead fails before intlocns = i then the registry location is unused 
and
'will be used for new trusted location if path not already in registy

On Error GoTo err_proc1:
'Allow Network Locations
reg.RegWrite strTrustedLocations & "\AllowNetworkLocations", 1, "REG_DWORD"

For intLocns = 1 To i
      reg.RegRead strLnKey & intLocns & "\Path"
      'If Path already in registry -> exit
      If InStr(1, reg.RegRead(strLnKey & intLocns & "\Path"), strPath) = 1 
Then MsgBox
CurrentProject.Path & " already in trusted locations": GoTo exit_proc
NextLocn:
  Next

  If intLocns = 999 Then
      MsgBox "Location count exceeded - unable to write trusted location to 
registry",
vbInformation, strTitle
      GoTo exit_proc
  End If
  'if no unused location found then set new location for path
  If intNotUsed = 0 Then intNotUsed = i + 1

On Error GoTo err_proc:
  strLnKey = strLnKey & intNotUsed & "\"
  reg.RegWrite strLnKey & "AllowSubfolders", 1, "REG_DWORD"
  reg.RegWrite strLnKey & "Date", Now(), "REG_SZ"
  reg.RegWrite strLnKey & "Description", Application.CurrentProject.Name, 
"REG_SZ"
  reg.RegWrite strLnKey & "Path", strPath & "\", "REG_SZ"
  MsgBox CurrentProject.Path & " added to trusted locations"
exit_proc:
  Set reg = Nothing
  Exit Function

err_proc0:
  Resume checknext

err_proc1:
  If intNotUsed = 0 Then intNotUsed = intLocns
  Resume NextLocn

err_proc:
  MsgBox Err.Description, , strTitle
  Resume exit_proc

End Function


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com 



More information about the AccessD mailing list