Sunday, July 16, 2006

Setting MP3 ID Tags with CDDBControl.dll

The CDDBControl DLL that can be downloaded from here can be used in VB or Java Script to programatically set and read the ID3 tags on an MP3 file. Lots of documentation exists on Google which shows you how to write the script, but today I discovered that this control will only operate if the user calling it has Administrator privileges.

Using tools from Sysinternals did not give me any additional information on why this restriction was true (as the file I was changing had got full control for the limited user that runs the script) so I added the DLL to Component Services as described below to solve the problem.

  1. Create a new user account with administrative permissions on the local machine. Give this account a very complex password and require that the password never expires.
  2. Login as this account and start Component Services (in the Administrative Tools area of Control Panel)
  3. Expand the Component Services tree until you get to COM+ Applications and right-click this node of the tree
  4. Choose New Application, Create an empty application and provide a name such as ID3Tag for the application. Keep the default of Server Application set.
  5. On the Set Application Identity page choose This User and enter the details for the current user account. It is important that you select this option and do not leave the default value of Interactive User set.
  6. Once the component is created, right-click the component and select the Pooling & Recycling tab. Set 1 minute for the Expiration Timeout value (unless your script takes longer to run) and click OK.
  7. Expand Component Services so that the contents of Components under your component are visible (this area will currently be empty)
  8. If you have already registered the control with regsvr32 then you need to unregister it using regsvr32 -u "path\CDDBControl.dll"
  9. Find the folder in which you have copied CDDBControl.dll and drag the dll into the Components container in Component Services
  10. You will get an error about some components not being able to be installed. You can click OK at this point.

You can now run your script as a limited user and when you call the id3.SaveToFile function the script will not fail with error 0x82fc100c