How to register OCX with SCCM 2012

Today, I’d a new challengue in my Customer. They needed to register a OCX to all their computer clients.

Perfect!! Start the party…

First of all, we need to create a folder in the SCCM repository. Copy in this folder this files and folders:

OCX SCCM Structure folder

Where in the folder OCXFile is located the OCX file. To register the OCX I’ve a cmd file like this one (RegisterOCX.bat):

@echo off

xcopy .\OCXFile\*.* “%programfiles(x86)%\FolderOCX” /e /c /i /g /h > nul

regsvr32 /s “%programfiles(x86)%\FolderOCX\OCXFile.ocx”

And to unregister the OCX I’ve this other cmd file (UnregisterOCX.bat):

@echo off

regsvr32 /u /s “%programfiles(x86)%\FolderOCX\OCXFile.ocx”

rd /S /Q “%programfiles(x86)%\FolderOCX”

Now, we only need to create a Application:

-Application with manually specify the aplication information

-Add a Deployment Type Manually, and with Type “Script Installer”

-Select Content Location. Folder created first of all.

-Select in “Installation Program” the RegisterOCX.bat

-Select in “Uninstall Program” the UnregisterOCX.bat

-Add a Clause to detect if the package is or not installed. For example, if exist the file ocx in the “%ProgramFiles(x86)%\folderOCX”

-Follow the wizard

Now, we can distribute the package to DP, and deploy to the target collection to install (register) or uninstall (unregister).