Register an OCX on Windows Server 2008, Vista and Windows 7


I am running into an issue here where I am trying to register an OCX  dynamically in an C++ MFC application in Windows Server 2008. The problem is that the OCX doesn't seem to be recognized at all, and the application just never opens.

I have also tried to register the OCX manually with the following command:
regsvr32 "Path\my.ocx"

and it gives me the following error:
The module "Path\my.ocx" was loaded but the call to DllRegisterServer failed with error code 0x80040200.

I have read around and found out that the problem seems to be because I have not run regsvr32 with admin rights. Is that correct?

The problem is that we are trying to update the current OCX of an old application.

My question is:
What would be the best way to register an OCX under Windows Server 2008/Vista/7 without having to worry about admin rights? I cannot use an InstallShield to update the existing applications that are already deployed.

Thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Amandeep Singh BhullarCommented:
You need to be administrator of pc, or run execute it as 'run as administrator'

Check the forum
TelDigAuthor Commented:
Thank you for your reply. Yes I am aware that running regsvr32 as administrator will register the OCX properly.

However, we have a lot of end users that need the OCX registered and they do not possesses admin rights.
What I am looking for is another way around this, because I cannot use an InstallShield to update the OCX component of our end users.

Any suggestions?
I'm not quite sure I understand what you are trying to do; whether you are an administrator or a programmer. You could try using a SysInternals took like PSEXEC to accomplish your goals; you could write a batch file that runs this tool one each machine that needs the update and run it from a console on your office PC if you have Administrative rights to all the machines requiring the update.

psexec \\computerName1,computerName2.,.,. -u DomainName\Administrator -p AdminPassword cmd "regsvr32 path\your.ocx"

or if you a list of computers in a file:

psexec @file -u DomainName\Administrator -p AdminPassword cmd "regsvr32 path\your.ocx"

If the update needs to be distributed to all computers in your domain this will work:

This command would run on all computers in the domain:
PSEXEC \\ -u DomainName\Administrator -p AdminPassword cmd "regsvr32 path\your.ocx"


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.