Posted 15 April 2012 - 08:29 PM
Here is How to interact with other scripts:
I was going to suggest looking at VBox Guest Additions.script
in Downloads section, but I can't seem to find it right now.
Forum Upgrade Issue I assume.
VirtualBox Guest Additions v4.1.8r75467
In this script, I write settings to:
C:Win7PE_SE_2011_05_20ProjectsWin7PE_SEVirtualTestVirtualBox.script
Here are some snippets
pButtonAddToVBox == Writes settings to VirtualBox.script
pButtonRemoveVBox == Removes settings to VirtualBox.script
The best way to do it, is to use a common line in the script,
in this case I used this line: Retrieve,FileSize,%ISOfileVar%,%sizeISO%
which should always be in the script, no matter what version or update is used.
[pButtonAddToVBox]
// First check to make sure the script exists
If,ExistFile,%ProjectDir%VirtualTestVirtualBox.script,Begin
// Show a simple message box
Message,"Adding SharedFolder to VirtualBox.script",INFORMATION,2
// If I have already added/modified VirtualBox.script, delete the added lines
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"ShellExecute#$cHide#$c#$pVBoxManage#$p#$c#$qsharedfolder add"
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"TxtAddLine#$c#$pDebugCmd#$p#$c#$qVBoxManage.exe sharedfolder add"
## Now replace:
// Retrieve,FileSize,%ISOfileVar%,%sizeISO%
## With:
// ShellExecute,Hide,%VBoxManage%,"sharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%"
// TxtAddLine,%DebugCmd%,"VBoxManage.exe sharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%",Append
// Retrieve,FileSize,%ISOfileVar%,%sizeISO%
## Note the #$x is the important part
TXTReplace,%ProjectDir%VirtualTestVirtualBox.script,"Retrieve#$cFileSize#$c#$pISOfileVar#$p#$c#$psizeISO#$p","ShellExecute,Hide,%VBoxManage%,#$qsharedfolder add %VBoxName% --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%#$q#$xTxtAddLine#$c%DebugCmd%#$c#$qVBoxManage.exe sharedfolder add #$pVBoxName#$p --name %VBoxShareFolderName% --hostpath %VBoxShareFolderPath%#$q#$cAppend#$xRetrieve#$cFileSize#$c%ISOfileVar%#$c%sizeISO%"
End
If,NotExistFile,%ProjectDir%VirtualTestVirtualBox.script,Message,"%ProjectDir%VirtualTestVirtualBox.script#$x Script not found, not modified",INFORMATION,5
//
## This one only removes the added entries
[pButtonRemoveVBox]
If,ExistFile,%ProjectDir%VirtualTestVirtualBox.script,Begin
Message,"Removing SharedFolder from VirtualBox.script",INFORMATION,2
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"ShellExecute#$cHide#$c#$pVBoxManage#$p#$c#$qsharedfolder add"
TXTDelLine,%ProjectDir%VirtualTestVirtualBox.script,"TxtAddLine#$c#$pDebugCmd#$p#$c#$qVBoxManage.exe sharedfolder add"
End
If,NotExistFile,%ProjectDir%VirtualTestVirtualBox.script,Message,"%ProjectDir%VirtualTestVirtualBox.script#$x Script not found, not modified",INFORMATION,5