Can Parallels be Scripted?

rwilkerson

Junior Member
In order to get SuperDuper to reliable create a system backup every night, I've written an AppleScript that quits any open VMs. That part seems to work great, but it would be even better if I could reopen them - or, at the very least, reopen the WinXP VM that runs in the background - when it's done.

Is this possible? I'm new to AppleScript, but I can't find any info on whether this is even possible, much less where to start.

Thanks.
 
rwilkerson said:
In order to get SuperDuper to reliable create a system backup every night, I've written an AppleScript that quits any open VMs. That part seems to work great, but it would be even better if I could reopen them - or, at the very least, reopen the WinXP VM that runs in the background - when it's done.

Is this possible? I'm new to AppleScript, but I can't find any info on whether this is even possible, much less where to start.

You don't need anu scripting support for that. Simply open the .pvs file and the virtual machine will start.
 
Okay, so maybe I spoke too soon...how do I execute a particular pvs file? I've looked for a way using bash and using AppleScript and found nothing. I'm used to shell scripting the app followed by the file (e.g. $ perl foo.pl), but I can't figure out how to do with with an APP bundle.

Thanks again.
 
How about this:

#! /bin/bash
/Applications/Parallels/Parallels\ Desktop.app/Contents/MacOS/Parallels /Users/your_username/Parallels/WinXP/WinXP.pvs

Save it as a shell script and make it executable.

I think you should be able to add it to the Advanced tab under:
Run shell script after copy completes
 
Thanks, ivel, I actually tried that and get this:

./after-scheduled-backup.sh: line 4: /Applications/Parallels/Parallels Desktop/Contents/MacOS/Parallels: No such file or directory

Maybe it doesn't like me reaching into the bundle? I got closer with an AppleScript:

tell application "Parallels Desktop"
open "~/Library/Parallels/desktop/vm-dsktp-winxp.pvs"
end tell

Unfortunately, I didn't get all the way. This just launches the window from which I have to choose a VM to open.
 
I saw the error of my ways (omitting the ".app") and made the correction. Now it works. Thanks, ivel. Very much appreciated.
 
I've been looking to do exactly this and came up with the following AppleScript, which quits Parallels after suspending the VM, moves the existing backup file to Trash, backs up the Windows 2003 VM folder, then starts the VM by opening the config file again and hides Parallels. It's scheduled to run with iCal.

tell application "Parallels Desktop" to quit
tell application "Finder"
move folder "Win2003" of folder "Backup" of disk "Data" to trash
with timeout of 1200 seconds
copy folder "Win2003" of folder "Parallels" of disk "Video" to folder "Backup" of disk "Data"
end timeout
end tell
tell application "Finder"
open document file "Microsoft Windows 2003.pvs" of folder "Win2003" of folder "Parallels" of disk "Video"
end tell
tell application "System Events"
set visible of process "Parallels Desktop" to false
end tell


It seems to work quite well. I've also got an Empty Trash command running at the start of each script to stop it filling up the drive. Would be nice if we could set the action on quit to "pause" rather than "suspend" and even nicer if we get proper scripting support in the next version.
 
Pausing the VM for long periods of time can leave it vulnerable. There is no state saved when it is paused - it is only prevented from receiving any CPU time. If OS X should die your machine could re-awake in an unknown state. This is especially true if it was writing to the registry at the time you paused it. Suspending freezes and records the state. If it was writing to the registery when suspended it will continue doing that when restarted. Even if the machine crashes after the VM is suspended.

This may not matter to you since you actively blow away all the data integrity features (backups...) with your script. There is a price to pay for that kind of thinking.
 
Back
Top