WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample code
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

CD Burn Code for XP


;CD BURN 
; Code tested on Windows XP
; Based on code found in this GOOGLE thread
; http://groups.google.com/groups?q=Write+these+files+to+CD+invokeverb&hl=en&lr=&ie=UTF-8&selm=O4RTPWEUDHA.3132%40tk2msftngp13.phx.gbl&rnum=2

;Change these four settings to suit your system
;=====================================
MyCDRW = "D:\"
MySource = "C:\Program Files\WinBatch\" ;Folder name only
MyCDName = "WBBackup"  ;Keep this short (6 Chars) as we add a YYMMDD to the

;Create YYMMDD String
ymdhms = TimeYmdhms()
mydatecode = StrCat(ItemExtract(1,ymdhms,":"), ItemExtract(2,ymdhms,":"),ItemExtract(3,ymdhms,":"))

;Find out where we have to write to
MyTarget = RegQueryValue(@RegCurrent,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders[CD Burning]")
DirChange(MyTarget)

;Copy the files into the Cd Burn Dir
BoxOpen("CD Burn",StrCat("Copying [" ,MySource ,"] to [" , MyTarget,"]" ))
AddExtender("wwsop34i.DLL")
aFileCopy(StrCat(MySource,"*.*"), MyTarget, 256)
BoxText(StrCat("Finished Copying files",@CRLF,"Ready For Writing To CDRW"))

;Kick off the CD Writing wizard
oApp = CreateObject("Shell.Application")
oApp.NameSpace(17).ParseName(MyCDRW).InvokeVerbEx("Write &these files To CD")

;Wait for "CD Writing Wizard" window to appear
AddExtender("wwctl44i.dll")
WinWaitExist("CD Writing Wizard", -1 )  ;Wait for window to exist ;TODO Check title and timeout value
window1=DllHwnd("CD Writing Wizard")
window2=cWndByClass(window1,`#32770`)

;Fill in CD Name field
ControlHandle=cWndByID(window2,14672)
cSetEditText(ControlHandle,StrCat(MyCDName,mydatecode))

;Select 'Close the wizard after the files have been written' checkbox
ControlHandle=cWndByID(window2,14674)
cCheckBox(ControlHandle,1)      ;Checks a checkbox

;Select &Next > button
ControlHandle=cWndByID(window1,12324)
cClickButton(ControlHandle)     

WinWaitClose("CD Writing Wizard")
Message("CD Burn","Finished Writing to CD") 

;Tidy Up
oApp = 0
exit


Article ID:   W16678
File Created: 2005:02:18:12:21:50
Last Updated: 2005:02:18:12:21:50