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.

Who is Participating?
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor 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.
Jeffrey CoachmanMIS LiasonCommented:
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
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.