Page 2 of 2

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

Posted: 28. Nov 2022, 20:23
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();

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

Posted: 6. Dec 2022, 09:54
by noteirak
Sadly I haven't had a chance to write code that uses the Unattended install, so I can't help you personally...