Re: Writing File to CD ROM




"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


.



Relevant Pages

  • Re: Writing File to CD ROM
    ... input to WXP's CD writing wizard, ... The script below has lots of message boxes to allow you to see what is ... Set objShell = CreateObject ... Do Until WshShell.AppActivate("CD Writing Wizard") ...
    (microsoft.public.scripting.vbscript)
  • Re: Vista - Burn to Cd
    ... Here is the script. ... Do Until WshShell.AppActivate("CD Writing Wizard") ... WshShell.SendKeys strCDName ...
    (microsoft.public.scripting.vbscript)
  • Re: [WR] round tuits
    ... Jackson Pillock wrote: ... I do, too many projects going, not enough time, priorities lean toward ... I started writing a precinct drama set in a locked psychiatric ward. ... Sent off my script. ...
    (misc.writing)
  • Re: crisis Perl
    ... As to writing good code to begin with, ... the top of the script. ... the "use warnings;" line won't actually change ... recommended declaring variables IN AS SMALL AS SCOPE AS POSSIBLE. ...
    (comp.lang.perl.misc)
  • Marginally archaeaology: Eight scripts that still cant be read
    ... WRITING is one of the greatest inventions in human history. ... literate civilisation at the time of the ... So how do you decipher an unknown script? ... there must be some link to a known language. ...
    (sci.archaeology)

Loading