Burning Multisession CDs with IMAPI2 in WSH - Building the burn image
(Page 3 of 5 )
In order to begin writing a new session to a disc, you must first check for any existing sessions on the disc to find where they end. This is so the IMAPI2 control knows where to begin writing the new session on the disc.
If Not objImageWriter.MediaHeuristicallyBlank Then
The ImageWriter object provides the MediaHeuristicallyBlank method that returns a Boolean value indicating whether or not there are existing sessions on the disc in the drive. You can create an If construct around this method to determine what course of action should be taken to create the current session image. If this value is true, you should import the existing sessions and append to that file system. If false, this indicates that we are writing the first session and we should create the file system.
On Error Resume Next
objFSI.MultisessionInterfaces = objImageWriter.MultisessionInterfaces
If Err.Number <> 0 Then
WScript.Echo "Multisession is not supported for this disc"
WScript.Quit
End If
On Error GoTo 0
If a current session does in fact exist, we can perform a quick check to determine whether or not writing multiple sessions is supported by the current recording device.
WScript.Echo "Importing data from the previous session..."
objFSI.ImportFileSystem()
If at this point, all is well, it means that the disc contains existing sessions and that writing multiple sessions is supported. We should then import the existing file system and append our new data to that.
Else
objFSI.ChooseImageDefaults(objRecorder)
End If
If the disc in the drive is blank, we should create a new file system inside of our session image. The ChooseImageDefaults does this easily by examining the drive and current media and creating a file system accordingly. In most cases, the default ISO9660 format will be used.
Next: Adding files and burning the image >>
More Windows Scripting Articles
More By Nilpo