Fighting with Windows Vista to Register COM Components

With great trepidation, I starting developing on my Windows Vista machine this month.  Although I had gotten the Vista computer last August, it was just too unreliable for me to risk my daily productivity with.  This unreliability included things like being unable to perform the very basic functions of an Operating System, such as file management.  Just a few examples of things I’ve encountered: 

  1. Couldn’t copy files because of an “Out of Memory” error (description and Vista Hotfix)
  2. Frequent File Explorer and Windows Photo Gallery crashes and lock ups when you rename a file (no workaround)
  3. Copying and extracting zip files is excruciatingly slow (description and workaround)

I generally like new technologies and I definitely like to see when User Interfaces are redesigned to make them easier to use.  Some of that happened with Vista but in general it is unreliable bloatware that will only serve to further diminish Microsoft’s reputation and market share.

But while I could carp about the technology failure that is Vista all day, the primary point of this post is to offer a few hints and “Gotchas” for those unfortunate souls who still need to do ATL/COM development.  Vista adds User Account Control security which adds some requirements for registering COM components.   So here is the advice:

  1. Create a shortcut to Visual Studio.NET that is set to “Run as Administrator” (Properties | Shortcut Tab | Advanced | Run As Administrator Checkbox)
    • Even though your account is an “Administrator” account in Vista, unless you select the “Run as Administrator” option your regsvr32 calls made during the build will fail.
    • Creating a shortcut and setting this option is the easiest way to do this so you won’t forget
  2. If like me, you create batch files to regsvr32 a bunch of COM dlls/components, you may suddenly notice that these batch scripts don’t work in Vista (even when you Run as Administrator).  To make these work in Vista:
    • Follow the same steps as above for creating a shortcut to the batch file and setting to Run as Administrator
    • When you Run as Administrator a batch file, Vista sets the current directory to C:\Windows\system32 (versus running from the current directory like it used to in the good ‘ol days), so you need to change the current directory back in your batch file
    • So here is a sample modified regsvr32 batch:

REM Stuff Added to get regsvr32 batch to run in Vista

REM Change the directory back to where this ran from (instead of System32)
set INSTALL_PATH=C:\MyFiles\PATH-TO-COM-Dlls\bin
cd %INSTALL_PATH%

REM Original Stuff that ran pre-Vista

regsvr32 MyCOMComponent.dll
pause
Advertisements

0 Responses to “Fighting with Windows Vista to Register COM Components”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: