Scripts and Guide by Soren Birk
This guide describes how to create a shared virtualbox between several users in a Windows domain environment.
This guide will use a virtual machine with Windows XP, but it could be any OS you like. The purpose of this
is to have a virtual environment for programs that can’t run on your primary Operating System.
The package creates a shortcut on all users’ desktop called “Create VirtualXP”. When someone clicks this icon,
a new shortcut will appear on that users’ desktop called “VirtualXP”. This shortcut loads the shared virtual machine,
disables auto-update and disables all the default pop-up messages.
Tested With:
Instructions:
Okay, this package is not that easy and you will need to do some preparations for it to work.
Tree:
CLIENT_DATA
├ setup.ins
├ uninstall.ins
├ delsub.ins
├ vbox-virtualxplogo.png
├ Certificate
│ └ oraclecert.cer
├ Icons
│ ├ registericon.ico
│ └ virtualxpicon.ico
├ VirtualBox
│ ├ common.cab
│ └ VirtualBox-X.X.XX-rXXXXX-MultiArch_amd64.msi
└ VMs
├ VirtualXp(.lnk)
├ Create_VirtualXP.bat
└ VirtualXP
├ VirtualXP.vbox
├ VirtualXP.vbox-prev
├ VirtualXP.vdi
└ Logs (folder)
Use Microsoft Orca to get the Msi-ID for the delsub-script.
Please read through the scripts, as you will need to apply your own domain-specific information.
; Author Soren Birk
[Actions]
requiredWinstVersion >= "4.11.2.6"
DefVar $MsiId$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $ProfilePath$
DefVar $UserProfileName$
DefStringList $UserProfileNamesList$
set $UserProfileNamesList$ = getOutStreamFromSection ('DosInAnIcon_list_profiledir')
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit these values -
; ----------------------------------------------------------------
Set $ProductId$ = "vbox-virtualxp"
Set $MinimumSpace$ = "5 GB"
Set $InstallDir$ = "%ProgramFiles64Dir%\Oracle\VirtualBox"
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough free space on %SystemDrive%, " + $MinimumSpace$ + " on the drive %SystemDrive% is needed for " + $ProductId$
isFatalError "Not enough free space"
; Stop the proces and set installation status as failed
else
comment "Show product logo"
ShowBitmap "%ScriptPath%\vbox-virtualxplogo.png" "VirtualBox - Virtual Windows XP"
if FileExists("%ScriptPath%\delsub.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.ins"
endif
Message "Installing " + $ProductId$ + " ..."
ChangeDirectory "%SCRIPTPATH%"
comment "Certificat is being installed"
DosInAnIcon_install_cert
comment "Start setup-program"
Winbatch_install
comment "Copying Virtual Machine"
Files_install
comment "Creating desktop shortcut"
LinkFolder_install
comment "Setting permissions for Domain Users (VMs)"
DosInAnIcon_set_rights
endif
[DosInAnIcon_install_cert]
certutil -addstore "TrustedPublisher" "%ScriptPath%\Certificat\oraclecert.cer"
[Winbatch_install]
msiexec /i "%ScriptPath%\VirtualBox\VirtualBox-X.X.XX-rXXXXX-MultiArch_amd64.msi" /l* "$LogDir$\$ProductId$.install_log.txt" /qb! ALLUSERS=1 REBOOT=ReallySuppress
[Files_install]
copy -s "%ScriptPath%\VMs\*.*" "%Systemdrive%\VMs\"
; copying icons also
copy -s "%ScriptPath%\icons\*.*" "%Systemdrive%\icons\"
[LinkFolder_install]
set_basefolder common_desktopdirectory
set_subfolder ""
; deleting standard shortcut
delete_element "Oracle VM VirtualBox"
; creating new shortcut
set_link
name: "Create VirtualXP"
target: "%Systemdrive%\VMs\Create_VirtualXP.bat"
parameters:
working_dir:
icon_file: "%Systemdrive%\icons\registericon.ico"
icon_index:
end_link
[DosInAnIcon_set_rights]
cacls C:\VMs /E /T /C /G "<yourdomain>\Domain Users":C
[DosInAnIcon_list_profiledir]
@echo off
dir "%Systemdrive%\Users" /b /ad
[Files_uninstall2]
del -sf "%Systemdrive%\Users\$UserProfileName$\Desktop\VirtualXP.lnk"
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
; Author Soren Birk
[Actions]
requiredWinstVersion >= "4.11.2.6"
DefVar $MsiId$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir$
DefVar $ProfilePath$
DefVar $UserProfileName$
DefStringList $UserProfileNamesList$
set $UserProfileNamesList$ = getOutStreamFromSection ('DosInAnIcon_list_profiledir')
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit these values -
; ----------------------------------------------------------------
Set $ProductId$ = "vbox-virtualxp"
Set $InstallDir$ = "%ProgramFiles64Dir%\Oracle\VirtualBox"
; ----------------------------------------------------------------
comment "Show product logo"
ShowBitmap "%ScriptPath%\vbox-virtualxplogo.png" "VirtualBox - Virtual Windows XP"
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub.ins"
endif
[DosInAnIcon_list_profiledir]
@echo off
dir "%Systemdrive%\Users" /b /ad
[Files_uninstall2]
del -sf "%Systemdrive%\Users\$UserProfileName$\Desktop\VirtualXP.lnk"
; Author Soren Birk
Set $MsiId$ = '{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}'
Message "Uninstalling " + $ProductId$ + " ..."
if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
comment "MSI id " + $MsiId$ + " found in registry, starting uninstall"
Winbatch_uninstall_msi
sub_check_exitcode
endif
comment "Deleting files"
Files_uninstall
comment "Deleting shortcuts"
LinkFolder_uninstall
for %prof% in $UserProfileNamesList$ do Sub_check_user
[Winbatch_uninstall_msi]
msiexec /x $MsiId$ /qb! REBOOT=ReallySuppress
[Files_uninstall]
del -sf "$InstallDir$\"
del -sf "%Systemdrive%\VMs\VirtualXP\"
[LinkFolder_uninstall]
set_basefolder common_desktopdirectory
set_subfolder ""
delete_element "Create VirtualXP"
[Sub_check_user]
Set $UserProfileName$ = "%prof%"
if not ($UserProfileName$ = "") and not ($UserProfileName$ = "All Users") and not ($UserProfileName$ = "Public") and not ($UserProfileName$ = "LocalService") and not ($UserProfileName$ = "NetworkService")
if FileExists("%Systemdrive%\Users\%prof%\Desktop\VirtualXP.lnk")
Files_uninstall2
endif
endif
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "Looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
isFatalError
endif
endif
endif
endif
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" registervm C:\VMs\VirtualXP\VirtualXP.vbox "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata global GUI/UpdateDate never "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setextradata global GUI/SuppressMessages remindAboutAutoCapture,remindAboutMouseIntegrationOn,showRuntimeError.warning.HostAudioNotResponding,remindAboutGoingSeamless,remindAboutInputCapture,remindAboutGoingFullscreen,remindAboutMouseIntegrationOff,confirmGoingSeamless,confirmInputCapture,remindAboutPausedVMInput,confirmVMReset,confirmGoingFullscreen,remindAboutWrongColorDepth xcopy "C:\VMs\VirtualXP.lnk" "C:\Users\%username%\Desktop\" /Y msg * "VirtualXP can now be found as a desktop shortcut"