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?
gemartiConnect With a Mentor Commented:
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"

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?
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.