isladogs
MVP / VIP
- Local time
- Today, 13:53
- Joined
- Jan 14, 2017
- Messages
- 18,823
Does anyone know how to detect using VBA whether Access has been opened as an administrator?
The reason for asking is that I need to write to the HKEY_LOCAL_MACHINE hive of the registry in one of my production databases.
Writing the code to do this isn't an issue for me
The issue is that changes to HKLM are not normally possible from within Access for security reasons.
This will cause the code to 'fail' - no error arises but no changes are made to the registry
However, this CAN be done in one of 3 ways:
1. Modify the registry so that standard users can edit the relevant key (Full Control) ... then open Access normally
2. Open Access as an administrator then run the code
3. Create a .reg file with the required change then run this outside Access
All of these work.
However, option 1 does open up the registry to potential misuse
My preference is for option 2 or 3 depending on how Access has been opened.
The idea is that if VBA detects run as admin = true then option 2 runs.
If false, option 3 is used.
The reason for asking is that I need to write to the HKEY_LOCAL_MACHINE hive of the registry in one of my production databases.
Writing the code to do this isn't an issue for me
The issue is that changes to HKLM are not normally possible from within Access for security reasons.
This will cause the code to 'fail' - no error arises but no changes are made to the registry
However, this CAN be done in one of 3 ways:
1. Modify the registry so that standard users can edit the relevant key (Full Control) ... then open Access normally
2. Open Access as an administrator then run the code
3. Create a .reg file with the required change then run this outside Access
All of these work.
However, option 1 does open up the registry to potential misuse
My preference is for option 2 or 3 depending on how Access has been opened.
The idea is that if VBA detects run as admin = true then option 2 runs.
If false, option 3 is used.