Selasa, 01 Mei 2012

[MS_AccessPros] Re: Reading Registry For Trusted Location

 

Darrell,

Here is a VBScript version:

Function KeyExists(sKeyPath)
KeyExists = False: If (sKeyPath = "") Then Exit Function
On Error Resume Next
CreateObject("wscript.shell").RegRead sKeyPath
Select Case Err
Case 0: KeyExists = True
Case &H80070002: Dim sErrMsg
sErrMsg = Replace(Err.Description, sKeyPath, "")
Err.Clear
CreateObject("wscript.shell").RegRead "HKEY_ERROR\"
KeyExists = Not (sErrMsg = Replace(Err.Description, "HKEY_ERROR\", ""))
Case Else: KeyExists = False
End Select
On Error GoTo 0
End Function

That help?

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile/Bill.Mosca

--- In MS_Access_Professionals@yahoogroups.com, "D" <embreydl@...> wrote:
>
> Greetings All,
>
> My company is upgrading from Windows XP and Office 2003 to Windows 7 and Office 2007. We have many Access applications that we need to add the location of the local database to the trusted locations in order for the vba code to run without receiving the security warning. I've found a program, AddPath.exe, that will allow us to add the trusted location to prevent the user from having to intervene and add the path to the trusted locations.
>
> My question is, how can I read the registry to see if the registry key for the trusted location already exists. Obviously, if it already exists it doesn't need to be added. Most of our applications have the users execute a .bat file that creates the folder for the database on the local machine and copies the latest version of the database from a network drive.
>
> Thanks in advance for your help.
>
>
> Darrell
>

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar