Burning CDs with the IMAPI2 Control - Identifying a Supporting Device
(Page 2 of 4 )
The IMAPI2 control exposes several different objects that we will be using. It may seem a little complicated at first glance but I’ll do my best to show you how it all fits together. You’ll need to know several different prog IDs. I’ll get into that in a bit. First, let’s start putting a script together.
intIndex = 0
strPath = "C:BurnTemp"
Set objDiscMaster = WScript.CreateObject("IMAPI2.MsftDiscMaster2")
You’ll want to begin your script by identifying a device index number and a path to the directory structure that you wish to burn to CD. Next, you’ll want to connect to the IMAPI DiscMaster object.
The process for burning DVDs is the same as it is for CDs. The only additional requirements are a supporting drive and supporting media.
The DiscMaster object enumerates all optical devices in the system and returns them as a string array containing each device identifier. Keep in mind that arrays are zero-base, so a 0 index represents the first optical drive in the system, a 1 represents the second, and so forth. If you are unsure which device to use, you can run the small script below to list information about each drive in order.
Const IMAPI_PROFILE_TYPE_CDROM = &H8
Const IMAPI_PROFILE_TYPE_CD_RECORDABLE = &H9
Const IMAPI_PROFILE_TYPE_CD_REWRITABLE = &HA
Const IMAPI_PROFILE_TYPE_DVDROM = &H10
Const IMAPI_PROFILE_TYPE_DVD_PLUS_RW = &H1A
Const IMAPI_PROFILE_TYPE_DVD_PLUS_R = &H1B
Set colDevices = CreateObject("IMAPI2.MsftDiscMaster2")
Set objRecorder = CreateObject("IMAPI2.MsftDiscRecorder2")
For Each objDevice In colDevices
objRecorder.InitializeDiscRecorder objDevice
WScript.Echo objRecorder.VendorId, objRecorder.ProductId
For Each strMountPoint In objRecorder.VolumePathNames
WScript.Echo "First Mount Point: " & strMountPoint
Exit For
Next
For Each Profile In objRecorder.SupportedProfiles
Select Case Profile
Case IMAPI_PROFILE_TYPE_CDROM
WScript.Echo "CD-ROM"
Case IMAPI_PROFILE_TYPE_CD_RECORDABLE
WScript.Echo "CD-R"
Case IMAPI_PROFILE_TYPE_CD_REWRITABLE
WScript.Echo "CD-RW"
Case IMAPI_PROFILE_TYPE_DVDROM
WScript.Echo "DVD-ROM"
Case IMAPI_PROFILE_TYPE_DVD_DASH_RECORDABLE
WScript.Echo "DVD-R"
Case IMAPI_PROFILE_TYPE_DVD_PLUS_RW
WScript.Echo "DVD+RW"
Case IMAPI_PROFILE_TYPE_DVD_PLUS_R
WScript.Echo "DVD+R"
End Select
Next
WScript.Echo
Next
This script enumerates each optical device on the system and then prints information about them in order. This information includes driver make and model along with some of the supported capabilities of the drive. This script is certainly not all-inclusive, but it should provide you with enough information to determine which device to use.
Next: Preparing a Disc Image >>
More Windows Scripting Articles
More By Nilpo