Consulting

Results 1 to 3 of 3

Thread: Check for and fix references automaticaly

  1. #1
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399

    Check for and fix references automaticaly

    So I recently just had a problem on a clients system with their Scripting Runtime Library (scrrun.dll)

    We deliver a .ade file (renamed to accdr to more easily work in access run time)

    I use FileSystemObjects for checking files, folders etc etc

    We had a problem where something un-registered the clients scrrun.dll file on their system causing our system to display a large error regarding not having access to a license for a feature.... (took me 3 hours to track down the problem because of this wonderfully "Descriptive" error)

    So what I am wanting to do now is setup an initial reference check and repair system that will be the FIRST item run on start up, as such It will need to ONLY use tools from the basic access VBA systems (I can't use a fso to check if scrrun.dll exists as that is the dll that DOES the checking!)

    so what I am looking for is a way to determine if a file exists without using fso, if it doesn't exist I need to find a way to download the file so I can then register it. I currently have a system in place using Micrsofot Internet Controls to downlaod files but could potentially have to repair that too so need to find a way to download a file without using that.

    Once the .dll files are downloaded I am fairly sure I can just regsvr32 the .dll file from a shell.

    as always any suggestions for approaching this are appreciated (My initial searches have turned up little but I am continuing to search while waiting on responses).

    Also thought I would include a short list of my references in case anyone knows of quirks of trying to fix or add them in the way I describe


    Visual Basic For Applications (shouldn't have a problem)
    Microsoft Access 12.0 Object Library (shouldn't have a problem as its part of the access runtime)
    OLE Automation
    Microsoft ActiveX Data Objects 2.5 Library
    Microsoft DAO 3.6 Object Library
    Microsoft Internet Controls
    Microsoft Scripting Runtime
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  2. #2
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    ok so I have located a potential option for determining if a file exists.

    So now I need to figure out how to download files nativly... (If possible)

    Option Compare Database
    Option Explicit
    
    
    Public Function StartupChecks()
    'Check for library problems
    CheckReferences
    
    
    'Check and initiate SQL connection
    CheckConnection
    End Function
    
    
    Private Sub CheckReferences()
    If ScriptingRuntimeExists = False Then
        FixScriptingRuntimeReference
    End If
    
    
    End Sub
    
    
    
    
    Private Function ScriptingRuntimeExists() As Boolean
    'Check for Scripting Run Time
    
    
    If (Dir("C:\Windows\System\scrrun.dll") = "") Then
        ScriptingRuntimeExists = True
        RegisterReference "C:\Windows\System\scrrun.dll"
        Exit Function
    End If
    
    
    If (Dir("C:\Windows\System32\scrrun.dll") = "") Then
        ScriptingRuntimeExists = True
        RegisterReference "C:\Windows\System32\scrrun.dll"
        Exit Function
    End If
    
    
    ScriptingRuntimeExists = False
    End Function
    
    
    Private Sub FixScriptingRuntimeReference()
    'download .dll file
    
    
    'register .dll file
    RegisterReference "C:\Windows\System\scrrun.dll"
    End Sub
    
    
    Private Sub RegisterReference(sFileName As String)
     ShellExecute 0, "runas", "cmd", "/c regsvr32 /s " & """" & sFileName & """", "C:\", 0 'SW_HIDE =0
    End Sub
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  3. #3
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Not sure what good searching for the file would do if it's just unregistered.
    If you've created a reference (edit ++ I see you have :-) ) you could check if it's broken.

    Dim r As Reference
    For Each r In Application.References
     If r.IsBroken Then DoFix
    Next
    Run at startup and if there's a problem
    - find the file (you could put a copy in the app folder at install?)
    - reregister
    - display message that the app needs to restart.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •