Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - Burning CDs in Windows XP with WSH
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 in Windows XP with WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-10-27

    Table of Contents:
  • Burning CDs in Windows XP with WSH
  • Behind the CD Writing Wizard
  • Building the Script
  • Finishing Up

  • 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 in Windows XP with WSH - Finishing Up


    (Page 4 of 4 )

    We’ve copied all of the files we wish to burn to the temporary staging area used by the CD Writing Wizard and launched the wizard.  Now we need to automate the steps of moving through the wizard.

    Do Until WshShell.AppActivate("CD Writing Wizard")

       WScript.Sleep 200

    Loop

    The WScript Shell object provides an AppActivate method that is used to bring an open window into focus.  By creating a loop we can ensure that our script does not continue until this action is actually possible.  This acts as a sort of timer that waits until the CD Writing Wizard is actually open on the system.

    WshShell.AppActivate("CD Writing Wizard")

    WshShell.SendKeys strCDName

    With the wizard open we can begin sending keystrokes to fill in the text fields in the wizard.  The wizard opens with the first text field in focus, so we can begin sending keystrokes right away using the WScript Shell’s SendKeys method.

    It’s a good practice to activate the Window before attempting to send any keystrokes.  This ensures that the correct window has focus when we begin typing the name of the CD to create.

    WshShell.AppActivate("CD Writing Wizard")

    WshShell.SendKeys "{Enter}"

    Now we need to continue to the next screen in the wizard.  Simply pressing the Enter key will do that, so we can send that as a keystroke -- again, making sure that the window is activated first.

    Do Until Not WshShell.AppActivate("CD Writing Wizard")

       WScript.Sleep 200

    Loop

    This will begin the CD writing process.  Now we have a little problem.  If we allow the script to exit, it will also close the CD Writing Wizard before it completes.  In order to prevent this, we can create another loop that effectively waits until the wizard is no longer available, suggesting that it has closed after completion.

    As you can see, although there is no direct method of writing files to a CD on Windows XP, WSH can be used to automate the built-in CD Writing Wizard to provide a scriptable alternative.  I hope that this example has shown you some of the flexibility of the WSH environment.  Now go out and find your own scripting workarounds.  Until next time, keep coding!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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 2 Hosted by Hostway
    Stay green...Green IT