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

Discussion about using the VirtualBox API, Tutorials, Samples.

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

Postby KrekerMeister » 28. Nov 2022, 20:23

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   Expand viewCollapse view
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();
KrekerMeister
 
Posts: 10
Joined: 14. Sep 2022, 17:00

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

Postby noteirak » 6. Dec 2022, 09:54

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!
noteirak
Site Moderator
 
Posts: 5220
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Previous

Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest