Run regsvr32 from VBA as Admin with or without a password

Posted on 2012-08-16
Last Modified: 2012-08-20
My Access deployment uses a 3rd party ActiveX control which requires registering with regsvr32 as Admin.

I found this code which works IF the Admin user has a password:

shell "runas /user:administrator " & zmagic.Strings.WrapInQuotes(strControlDLL, 2), vbNormalFocus

Open in new window

This opens cmd.exe window with a prompt for the admin password but errors out if you just press Enter because there is not Admin password.

On my client machines, I can't guarantee there will or will not be an Admin password so I need code that will allow me to register the DLL whether there is a pw or not.

Question by:Kaprice
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    Well the basic code to register a dll is:
        c:\regsvr32.exe c:\SomeFolder\sample.ocx

    Does this work form the command prompt?

    If so, then you can wrap it in code and run it from VBA
    LVL 84

    Accepted Solution

    I don't know that you can work around this in that manner, and I'm not sure EE would allow us to answer the question anyway (it could be considered circumventing security).

    It would be much better to use an installer (like InnoSetup, InstallShield, etc) to install your Access db, and have the user do so with an Admin level login. This would install the controls correctly and register them with the proper permissions.

    Author Closing Comment

    I wasn't sure how to grade this. It wasn't the answer I was hoping for, meaning the answer doesn't solve my problem, so a B or C seemed appropriate. But, the answer does appear to be accurate, meaning there really is no solution to my question, other than the 3rd party tools mentioned in the answer.

    So, I chose "A" (Excellent) since it's not the Expert's fault that VBA or Windows does not provide a way to do what I wanted.

    Thanks for your help on this.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now