Re: Writing File to CD ROM
- From: "Paul Randall" <paulr90@xxxxxxx>
- Date: Tue, 12 May 2009 14:40:09 -0600
"SAC" <someone@xxxxxx> wrote in message
news:eIG9tjg0JHA.1372@xxxxxxxxxxxxxxxxxxxxxxx
I have files waiting to be written to a CD Rom and I would like to do this
in vbscript.
Is this possible?
If so, how would I do this?
Thanks for your help.
Yes, it is possible.
One way, using the shell invokeverbex method, and SendKeys to provide input
to WXP's CD writing wizard, is shown below. Note that SendKeys is prone to
failure due to other processes making their window active while your script
is sending keystrokes to your window.
The script below has lots of message boxes to allow you to see what is
happening. The message box after the statement doing the copyhere also
ensures that the copyhere process is complete. This method does not pause
the script until it is finished, and if a lot of stuff is copied, then you
will see Windows standard file copy progress box too.
I have tried scripting the use of various free command line tools for
writing stuff to CD, but have not yet found what I consider a completely
satisfactory solution. Nero (including the free versions that are packaged
with internal/external CD/DVD writers) includes a command line tool for
burning CDs; it has lots of options and capabilities. I have not been able
to get VBScript to read the tool's output to StdOut in real time, so my
script can't monitor the writing progress.
Let us know if you find something that works well for you.
'Copy all items from a source directory to the WXP CD Burning folder
' and then write them to CD.
'Note that hidden items in the source directory are not copied, but
' hidden items within subfolder items are copied.
Option Explicit
Dim strCDDriveLetter, strSourceDirectory, strCDLabel
Dim WshShell, objShell, strBurnDirectory, objShellFolder
' Provide the drive letter of your CD burner
strCDDriveLetter = "D:\"
' Provide the source directory
strSourceDirectory = "F:\Maytag"
' Provide a volume name for your CD (16 characters max)
strCDLabel = "16-chars CD Name"
Const MY_COMPUTER = &H11
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
strBurnDirectory = WshShell.RegRead( _
"HKCU\Software\Microsoft\Windows\CurrentVersion\" _
& "Explorer\Shell Folders\CD Burning")
MsgBox "CD Burn Folder path:" & vbCrLf & strBurnDirectory & vbCrLf & _
"Source Folder path:" & vbCrLf & strSourceDirectory & vbCrLf & _
"CD Burner Drive letter: " & strCDDriveLetter
Set objShellFolder = objShell.Namespace(strSourceDirectory)
'
objShell.Namespace(strBurnDirectory).CopyHere objShellFolder.Items
MsgBox "Click OK when copy to burn directory is complete"
objShell.NameSpace(&H11&).ParseName(strCDDriveLetter).InvokeVerbEx( _
"Write &these files to CD")
Do Until WshShell.AppActivate("CD Writing Wizard")
WScript.Sleep 200
Loop
MsgBox "The CD Writing Wizard showed up, will use SendKeys to " & _
"fill in the CD Label (aka CD Name)."
WshShell.AppActivate("CD Writing Wizard")
WScript.Sleep 1000
WshShell.SendKeys strCDLabel
MsgBox "Click OK to SendKeys the Enter Key to start recording."
WshShell.AppActivate("CD Writing Wizard")
WshShell.SendKeys "{Enter}"
Do Until Not WshShell.AppActivate("CD Writing Wizard")
WScript.Sleep 200
Loop
MsgBox "Done"
-Paul Randall
.
- Follow-Ups:
- Re: Writing File to CD ROM
- From: SAC
- Re: Writing File to CD ROM
- From: Stefan Kanthak
- Re: Writing File to CD ROM
- References:
- Writing File to CD ROM
- From: SAC
- Writing File to CD ROM
- Prev by Date: Re: How to find the operating system bit (x86/x64/ia64)
- Next by Date: HTML webpage within IE loagin HTA with agruments
- Previous by thread: Writing File to CD ROM
- Next by thread: Re: Writing File to CD ROM
- Index(es):
Relevant Pages
|
Loading