• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1862
  • Last Modified:

Run regsvr32 from VBA as Admin with or without a password

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.

1 Solution
Jeffrey CoachmanCommented:
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
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
KapriceAuthor Commented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now