Please help me understand with simple examples of using API in Java.

Discussion about using the VirtualBox API, Tutorials, Samples.
KrekerMeister
Posts: 15
Joined: 14. Sep 2022, 17:00

Re: Please help me understand with simple examples of using API in Java.

Post by KrekerMeister »

When using the unnatended class, did I find a bug or am I doing it wrong? If you set GuestAdditionsInstall to true and add the postInstallScriptTemplatePath attribute, then postInstallScriptTemplatePath will overwrite the guestAdditionsInstall script file that was created in the machine's unnatended folder. Then the add-ons will not be installed and will simply be executed after the installation script. Or in short, the postscript attribute removes the installation scripts of the guest additions and adds its own to the file scripts.

Code: Select all

IUnattended un = vbox.createUnattendedInstaller();
        createmachine(mgr, vbox, machinename);
        IMachine machinefind = vbox.findMachine(machinename);
        ISession session = mgr.getSessionObject();
        machinefind.lockMachine(session, LockType.Write);
        un.setIsoPath("F:\\ru_windows_8.1_professional_vl_with_update_x64_dvd_4050520.iso");
        un.detectIsoOS()
        IMachine machwrite = session.getMachine();
        un.setMachine(machwrite);
        un.setUser(pcname);
        un.setFullUserName(machinename);
        un.setProductKey("");
        un.setPostInstallScriptTemplatePath("K:\\VM Lib\\PostScriptps.ps1");
        un.setInstallGuestAdditions(true);
        un.setTimeZone("Russian Standard Time");
        un.setLocale("ru_RU");
        un.prepare();

        un.constructMedia();
        un.reconfigureVM();
        un.done();
        session.unlockMachine();
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Please help me understand with simple examples of using API in Java.

Post by noteirak »

Sadly I haven't had a chance to write code that uses the Unattended install, so I can't help you personally...
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply