INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Adding Windows 7 registry values for Trust Center from Access 2013 VBA

Adding Windows 7 registry values for Trust Center from Access 2013 VBA

(OP)
I have an application that is distributed to almost 30 sites with some sites having multiple computers. I have a secondary database on a common server that holds objects that need updating at each of the sites. When the site opens the database, it goes out and checks to see if there is a difference in the version number that is on the server compared to the local version. If the versions are different, the database copies the objects that need updating and replaces them in the local database. The problem that I am having is the Trust Center settings are causing a security warning to appear for each object that needs to be copied and the user needs to click on an open button for each object. I need to write to the registry to add the folder location as a trusted location so these warnings don't appear each time. Any idea on how I can accomplish this?

I hope this makes sense and thank you in advance for any and all advice.

flush

Michael

It is said that God will give you no more than you can handle. I just wish God didn't think I was just a bad ass.

RE: Adding Windows 7 registry values for Trust Center from Access 2013 VBA

I use a vbscript file that creates a folder in the user's system folder, sets it to trusted, copies the front-end to the folder, and then runs the application. I think you should be able to pull what you need from this code. It actuall should work for most versions of Access through 2013.

CODE --> vbscript

'===================
' File: TrustCopyRun.vbs
'===================
   Const SystemFolder= 1
   Dim fso  'to be used for file related code
   Dim SysFolder
   Dim SysFolderPath
   dim strUserLogin 
   Dim RegEdPath
   Dim strAppFolder
   Dim strAppName
   Dim strAppFile
   Dim strAppNetworkFile 

'==============================================================
'  edit the values in the next three lines to match your application and network location
   strAppName = "YourApp"
   strAppFile = "YourApp.accdb"
   strAppNetworkFile = "\\ServerName\AppFolder\YourApp.accdb"
'==============================================================
   Set fso = wscript.CreateObject("Scripting.FileSystemObject")
   Set SysFolder =fso.GetSpecialFolder(SystemFolder)
   SysFolderPath= SysFolder.Path

   'initialize the script shell object
   Set WshShell = WScript.CreateObject("WScript.Shell")
   strUserLogin = WshShell.ExpandEnvironmentStrings("%USERNAME%") 
   strAppFolder = "C:\users\" & strUserLogin & "\" & strAppName
   if not fso.FolderExists(strAppFolder) Then
      fso.CreateFolder strAppFolder
   End If

   'SNOW4 Office 12
   RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\"
   WshShell.RegWrite  RegEdPath  ,strAppName
   'Write the values into the registry
   WshShell.RegWrite  RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
   WshShell.RegWrite  RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"

   'SNOW5 Office 14
   RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\"
   WshShell.RegWrite  RegEdPath  ,strAppName
   'Write the values into the registry
   WshShell.RegWrite  RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
   WshShell.RegWrite  RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"
   
    'SNOW5 Office 15
   RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Access\Security\Trusted Locations\"
   WshShell.RegWrite  RegEdPath  ,strAppName
   'Write the values into the registry
   WshShell.RegWrite  RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
   WshShell.RegWrite  RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"

   'copy the application file from the network location to the local folder 
   fso.CopyFile strAppNetworkFile ,strAppFolder & "\", 1
   'run the application
   wshshell.Run strAppFolder & "\" & strAppFile

wscript.Quit 

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close