====== Oracle VirtualBox (for OS compatibility problems) ====== //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:** * OPSI 4.0.2.4 * Winst 4.11.3.3 * Windows 7, 64-Bit **Instructions:** Okay, this package is not that easy and you will need to do some preparations for it to work. * Prepare VirtualBox-installer (.msi): * Start off by downloading VirtualBox for Windows from: https://www.virtualbox.org/wiki/Downloads * Open a command prompt and write: \VirtualBox-X.X.X-XXXXX-Win.exe –extract * You can now find the .msi-file under Appdata → Local → Temp → Virtualbox. You will need both the .msi-file (x64) and the common.cab. * Copy them to CLIENT_DATA\VirtualBox * Prepare the certificate for silent install: * You should now install the program (just use the .exe-file) – accept the certificate when prompted. * When installed, go to Run… and write certmgr.msc. * Navigate to “trusted publishers” → Right click "Oracle Corporation" and browse to Export… - export the certificate as “oraclecert.cer”. * Copy the certificate to CLIENT_DATA\Certificate * Prepare the virtual machine: * Create a new virtual machine in VirtualBox (doesn’t have to be Windows XP – could also be linux ect.) and set it up with the software you like. * Network could cause problems, when you install the package to a new PC, if “bridged” mode is set – I use NAT. * When the virtual machine is created as you like, shut it down. * Copy the VM-folder from \VirtualBox VMs\ to CLIENT_DATA\VMs-folder. * Prepare the user-specific shortcut: * Create a shortcut to your desktop with a path to: "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm VirtualXP. * Create a folder called C:\icons and copy the icon you want for the VirtualXP-shortcut to this folder. * Finally set the icon for the shortcut. * Copy this shortcut to CLIENT_DATA\VMs-folder. * Prepare the .bat-file: * Create a .bat-file (scroll to the bottom of this guide) and copy it to CLIENT_DATA\VMs. **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.// ==== setup.ins ==== ; 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 "\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 ==== uninstall.ins ==== ; 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" ==== delsub.ins ==== ; 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 ==== Create_VirtualXP.bat ==== "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"