heres the example script for launching the restore process (after having made the image... and booted up on bootdisk/alternat vol
set tWhatToRestore to lastASitem(":", (path to me as string))
set tWhereToRestore to choose folder with prompt "Select a volume and press 'Choose'"
launch application "Apple Software Restore"
--NOTE! Launching an application from AppleScript is different than opening it with a
--"Tell application" line. When you "launch" ASR 1.3.2 from AppleScript, this tells ASR
--to enter "background" mode. This replaces the need for the "LaunchASR" OSAX
tell application "Apple Software Restore"
with timeout of 1000000 seconds
try
Restore tWhatToRestore to ¬
tWhereToRestore placing in entire volume ¬
preprocess erasing disk ¬
copying everything ¬
warning true ¬
barber pole speed 10 with checksum, removing unwanted files and erasing on failure
on error tErrorMessage number tErrorNumber
display dialog ("Error: " & "[" & tErrorMessage & "]" & ", [" & tErrorNumber & "]")
end try
end timeout
quit
end tell
--Note on the first parameter to the 'Restore' command: If you pass in a pathname or alias, ASR
--will assume it's a single image and restore it (if present). If you simply pass in a string
--(as in the example), ASR will look in the 'Configurations' folder for an image with that name.
--If the 'Configurations' folder is not present, ASR will look in the same folder as itself
--for an image with that name.
on lastASitem(delim, theText)
-- returns the portion of <theText> that follows the last <delim>
set theText to theText as string
if delim is in theText then
set theText to lastASitem(delim, (characters ((offset of delim in theText) + 1) through (length of theText) of theText))
end if
return theText
end lastASitem
and the scan for ASR script (both are from ASR v1.3.2)
property kImageSelectPromptString : "Select a image to scan"
property kImageIsReadWrite : "Selected image is read-write and cannot be scanned. Convert it to read-only (or read-only compressed) and try again"
property kImageDoesNotCheck : "The Selected image does not appear to be in the correct format, or created with Disk Copy. Click convert to convert it to Disk Copy format, or stop to halt the scan."
property kOkButton : "OK"
property kStopButton : "Stop"
property kConvertButton : "Convert"
property kImageScanOSAXString : "Scripting Additions:ImageScan"
property k8ImageScanOSAXString : "ImageScan"
property kMissingAnOSAXString : "This droplet requires the ImageScan OSAX. Please put it into your Scripting Additions folder"
property kInfoMessage : "This script will prompt you for a read-only disk image, verify it's image checksum and volume structures, then scan it and generate information that ASR needs to restore it."
property kDontShowAgainButton : "Don't show again"
property kDisplayInfoMessage : 0
on run
if kDisplayInfoMessage is 1 then -- This doesn't work yet...
set tResult to display dialog kInfoMessage buttons {kDontShowAgainButton, kOkButton} default button kOkButton with icon note
if button returned of tResult is kDontShowAgainButton then
set kDisplayInfoMessage to 0
end if
end if
try -- Check to see if the ImageScan osax exists
set x to alias ((path to extensions as string) & kImageScanOSAXString)
on error
try
set x to alias ((path to scripting additions as string) & k8ImageScanOSAXString)
on error
try -- Assume I'm being run from Disk Copy, and want to see if it's in the 'Scripts' folder
set x to «event JonBImSc»
on error tErrMessage number tErrNumber
if tErrNumber is "-1708" then -- ImageScan is not available
return kMissingAnOSAXString
end if
end try
end try
end try
try
tell application "Disk Copy"
set tImageToScan to «event UTILSEL1» given «class SELp»:kImageSelectPromptString
set tIsROImage to «class Xcrc» of «class DImg» tImageToScan
end tell
on error tErrMessage number tErrNumber
if tErrNumber = -128 then -- The user clicked cancel
return "User cancelled operation"
else
display dialog ("There was a problem selecting the image: " & tErrMessage & " (" & tErrNumber & ")") buttons {kOkButton} default button kOkButton
ErrorSound()
return
end if
end try
if tIsROImage as string = "00000000" then
display dialog kImageIsReadWrite buttons {kOkButton} default button kOkButton
ErrorSound()
return
else
try -- check image and verify checksum here
tell application "Disk Copy"
set tResult to «event ddskChek» tImageToScan
set tImageConsistency to «class Rch1» of tResult
set tImageErrors to «class Rch2» of tResult
set tChecksumResult to «event ddskVcrc» tImageToScan
set tImageChecksumValidity to «class Vlid» of tChecksumResult
end tell
on error tErrMessage number tErrNumber
display dialog ("There was a problem checking the image: " & tErrMessage & " (" & tErrNumber & ")") buttons {kOkButton} default button kOkButton
ErrorSound()
return
end try
if (tImageConsistency is not true) or (tImageChecksumValidity is not true) then
if tImageErrors > 1 then
display dialog ("There is a problem with this image. Please check it and try again") buttons {kOkButton} default button kOkButton
ErrorSound()
return
end if
set tResult to display dialog (kImageDoesNotCheck) buttons {kConvertButton, kStopButton} default button kStopButton
if button returned of tResult is kConvertButton then
ConvertImage(tImageToScan)
else
ErrorSound()
return
end if
end if
try
set tResult to «event JonBImSc» tImageToScan with «class omt0» and «class chek»
on error tErrMessage number tErrNumber
display dialog ("There was a problem scanning the image: " & tErrMessage & " (" & tErrNumber & ")") buttons {kOkButton} default button kOkButton
ErrorSound()
return
end try
end if
try
tell application "Disk Copy"
«event UTILLOG » "We've just scanned an image for ASR!" with «class TSMP»
«event UTILLOG » "Image " & "“" & (tImageToScan as string) & "”" & " was scanned."
«event UTILLOG » "It has " & («class scnt» of tResult as string) & " files in it, and it's file checksum is $" & («class 1hsm» of tResult)
if «class sypt» of tResult is not "" then
«event UTILLOG » "It's System folder is located at " & («class sypt» of tResult as string) & ", " & ¬
"and has " & («class syct» of tResult as string) & " files in it."
end if
end tell
on error tErrMessage number tErrNumber
display dialog ("There was a problem updating the log: " & tErrNumber & return & " but the image was scanned") buttons {kOkButton} default button kOkButton
ErrorSound()
return
end try
try -- Just play a little tune to indicate that we're finished...
«event aevtplsn» "Done"
end try
end run
on ConvertImage(tImageToConvert)
display dialog ("Coming soon...")
end ConvertImage
on ErrorSound()
try
«event aevtplsn» "Error"
end try
end ErrorSound
------------------------------------------------------------------------------------------
--
-- GetPath - Returns the beginning of a input string deleting info after the last colon
--
-- Parameters:
-- Type string: aString
--
-- Returns:
-- All characters from the first character to the last colon in the string
--
-- Example:
-- GetPath("Macintosh HD:Desktop Folder:FY94 budget")
-- ==> "Macintosh HD:Desktop Folder:"
--
on GetPath(aString)
repeat
if last character of aString is not ":" then
set aString to (characters 1 thru ((length of aString) - 1) of aString) as string
else
exit repeat
end if
end repeat
display dialog aString
return aString as string
end GetPath
------------------------------------------------------------------------------------------