Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Shell RegEdit
Adam Schwanz 
           
4 years ago
I'm making a module/form to setup the registry values for a trusted location trying to save some time on users with Access RunTime. I know there's some other tools out there that can add the registry keys for trusted locations but it's not as fun if I don't make it myself LOL.

Anyone know anything about setting registry values with vba for the currently logged in/other user if they are not an administrator? Running this works on the admin account but if you run it on a user account and give admin credentials, it adds it to the admin's HKEY_CURRENT_USER not the users.

Also note I'm trying to do it out of Access, I have a batch file I can just execute from Access but I'm looking to make it more difficult than it has to be :).

    Dim ShExec As Object
    Set ShExec = CreateObject("Shell.Application")
    Dim RegPath As String
    
    'Set the Path to the registry location
    RegPath = Chr(34) & "HKEY_Current_User\Software\Microsoft\Office\" & Application.Version & "\Access\Security\Trusted Locations" & Chr(34)
    
    'Includes AllowNetworkLocations DWORD 1 if True
    If AllowNetworkLocations = True Then
    ShExec.ShellExecute "reg", "add " & RegPath & " /v AllowNetworkLocations /d 1 /t REG_DWORD /f", "", "runas", 0
    End If
    
    'Add a registry entry for the current folder location
    ShExec.ShellExecute "reg", "add " & RegPath & "\AccessRunTime /v Path /d """ & Application.CurrentProject.path & """ /t REG_SZ /f", "", "runas", 0
    
    'Includes AllowSubFolders DWORD 1 if True
    If AllowSubFolders = True Then
    ShExec.ShellExecute "reg", "add " & RegPath & "\AccessRunTime /v AllowSubFolders /d 1 /t REG_DWORD /f", "", "runas", 0
    End If
    
    MsgBox "Completed Adding Registry Values"
Alex Hedley  @Reply  
           
4 years ago
Alex Hedley  @Reply  
           
4 years ago
Adam Schwanz OP  @Reply  
           
4 years ago
Thanks Alex :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 8:30:11 AM. PLT: 1s