Everything about my daily life as a programmer/Electrical Engineer!

Useful Powershell Script

Have you ever had a list of .ISO's that you needed to burn but were tired of setting each iso to burn individually. I often have this problem when I need to burn for instance the 5 iso's that vista shipped with. Below is a useful powershell script that will scan a directory or directories, find the ISO file, and ship it to ImgBurn. I have it setup so that it deletes the image. All you have to do is wait for the drive to eject your dvd.

function burn()
#get the files and ship them to burn-file
dir -recurse -include *.iso -path c:\,d:\,e:\ | foreach { burn-file $_.FullName }

function burn-file($filename)
#call img burn with the nessessary arguments
. "c:\Program Files\ImgBurn\ImgBurn.exe" /mode ISOWRITE /WAITFORMEDIA /start /close /DELETEIMAGE /EJECT /SRC $filename
#Wait for IMGBURN to finish (right now you can only have one open at a time)
while ( (get-process | where{$_.ProcessName -eq "ImgBurn"}) -ne $null)
#sleep for a bit to let the processor work on burning
Start-Sleep –s 10
#tell the user what file you are still working on
"waiting for $filename to complete"


#call the burn function

kick it on DotNetKicks.com

No comments: