Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Burning CDs with the IMAPI2 Control
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Burning CDs with the IMAPI2 Control
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-11-03

    Table of Contents:
  • Burning CDs with the IMAPI2 Control
  • Identifying a Supporting Device
  • Preparing a Disc Image
  • Burning the Disc

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek