Error 0x80bb0005 while executing Process on Windows Guest

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Error 0x80bb0005 while executing Process on Windows Guest

Post by Skalden »

Hi!

Im currently trying to build a process that'll start up a Virtual Machine, opens the IE with a specific Adress and makes a Screenshot. I got the complete code running, but I'm simply not able to create the process on the Guest machine.

Code: Select all

        ISession session = mgr.getSessionObject();
        machine.lockMachine(session, LockType.Shared);
        
        IConsole console = session.getConsole();
        IGuest guest = console.getGuest();
        Long time = 50L;
        IGuestProcess gp = null;
        
        System.out.println("Logging into Guest System");
        
        IGuestSession gs = guest.createSession("IEUser", "Passw0rd!", "", "");
        
        System.out.println("Hoping to be accepted...");
        
        GuestSessionWaitResult result = gs.waitFor(1L, time);

        if(result == GuestSessionWaitResult.Start){
            System.out.println("Guest Session is " + gs.getStatus());
            System.out.println("Got accepted!");
            
            Adress = "\"" + Adress + "\"";
            System.out.println("Starting IE with Adress: " + Adress);
            String iexplore = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"";
            //String iexplore = "\"C:\\Program/ Files\\Internet/ Explorer\\iexplore.exe\"";
            //String iexplore = "C:\\Program/ Files\\Internet/ Explorer\\iexplore.exe";
            System.out.println("Console Call will be: " + iexplore + " " + Adress);
            
            List<String> arguments = new ArrayList<>();
            arguments.add(Adress);

            gp = gs.processCreate(iexplore, arguments, null, null, 0L);
            System.out.println("Started the process");
            
            List<IGuestProcess> gps = new ArrayList<>();
            gps = gs.getProcesses();
            for(int i=0;i<gps.size();i++){
                IGuestProcess gp_foo = gps.get(i);
                System.out.print("Name: " + gp_foo.getName()  + " ");
                System.out.print("Ex. Path: " + gp_foo.getExecutablePath() + " ");
                System.out.print("PID: " + gp_foo.getPID() + " ");
                System.out.println("Status: " + gp_foo.getStatus());
            }
            
            
            
            List<ProcessWaitForFlag> foo = new ArrayList<>();
            foo.add(ProcessWaitForFlag.Start);
            
            ProcessWaitResult waitResult = gp.waitForArray(foo, 0L);
            if(waitResult == ProcessWaitResult.Start){
                System.out.println("Process Load finished");
            }
            
        }
I just never starts the Internet Explorer, the process state is always in error and the program exits with an exception thrown:

Code: Select all

Exception in thread "main" org.virtualbox_5_0.VBoxException: The function "waitForArray" returned an error condition: "The specified file is an invalid name" (0x80bb0005)
	at org.virtualbox_5_0.IProcess.waitForArray(IProcess.java:165)
	at virtualbox_local_getscreenfromurl.VirtualBox_Local_GetScreenFromUrl.openURLinIEandSaveToPath(VirtualBox_Local_GetScreenFromUrl.java:125)
	at virtualbox_local_getscreenfromurl.VirtualBox_Local_GetScreenFromUrl.main(VirtualBox_Local_GetScreenFromUrl.java:56)
Caused by: org.mozilla.xpcom.XPCOMException: The function "waitForArray" returned an error condition: "The specified file is an invalid name" (0x80bb0005)
	at org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native Method)
	at org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java:143)
	at com.sun.proxy.$Proxy11.waitForArray(Unknown Source)
	at org.virtualbox_5_0.IProcess.waitForArray(IProcess.java:160)
	... 2 more
Java Result: 1
I checked for the existance of that file, tried to execute it via "start iexplore htp:/....", but the same error :(
I also tried to start other programs, like cmd.exe - no success either.

Hope you can help out!

PS: I'm using the Windows 7 Developer VM from Microsoft with IE8 preinstalled.
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

More a warning than an error, you seem to not have notice that waitTime in IGuestSession::waitFor(eventId,waitTime) is in milliseconds, and not seconds. Waiting 5 milliseconds is a bit short :)
I would also recommend to use the GuestSessionWaitForFlag Enum instead of the int value, makes it easier to read later on. That means switching to IGuestSession::waitForArray()

You do not wait for the process to start at IGuestSession::processCreate() - instead you use null (4th arg). You should instead use ProcessCreateFlag.WaitForProcessStartOnly: this allow you to use the timeout value (5th arg) for a start timeout instead of a process execution time limit. This also gives you a nice blocking wait until the process is created (but not running!)
Finally, at IProcess.waitForArray(), you should really use a good timeout and not just 0.

VBox 5.0.x (at time of writting) is a bit tricky on this compared to 4.x and a change at processCreate() is simply not documented.
In 5.0, the 1st argument of processCreate() is actually some labeling (maybe in ps output?) for the process. You need to put that value in the 2nd argument as well.
You can omit the 1st argument (give it null) and the first string given in the 2nd argument will be used. So you don't need to repeat anything.

I have no good experience with starting Windows process that will need to interact with the desktop but you might also need to adapt the environment variable for the session or the process.
More on that later if you need it.

Finally, quotes should not be used AFAIK and might confuse the processing.

To sum it up, this is how you would do it :

Code: Select all

        ISession session = mgr.getSessionObject();
        machine.lockMachine(session, LockType.Shared);
        
        IConsole console = session.getConsole();
        IGuest guest = console.getGuest();
        Long time = 50 *1000L; // let's make it 50 seconds
        IGuestProcess gp = null;
        
        System.out.println("Logging into Guest System");
        
        IGuestSession gs = guest.createSession("IEUser", "Passw0rd!", "", "");
        
        System.out.println("Hoping to be accepted...");
        
        GuestSessionWaitResult result = gs.waitForArray(Arrays.asList(GuestSessionWaitForFlag.Start), time); // let's use waitForArray to be clear

        if(result == GuestSessionWaitResult.Start){
            System.out.println("Guest Session is " + gs.getStatus());
            System.out.println("Got accepted!");
            
            System.out.println("Starting IE with Adress: " + Adress);
            String iexplore = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
            System.out.println("Console Call will be: " + iexplore + " " + Adress);
            
            List<String> arguments = new ArrayList<>();
            arguments.add(iexplore);
            arguments.add(Adress);

            gp = gs.processCreate(null, arguments, null, Arrays.asList(ProcessCreateFlag.WaitForProcessStartOnly), time);
            System.out.println("Created the process"); // reworded syso to make it clear where we're at
            
            List<IGuestProcess> gps = new ArrayList<>();
            gps = gs.getProcesses();
            for(int i=0;i<gps.size();i++){
                IGuestProcess gp_foo = gps.get(i);
                System.out.print("Name: " + gp_foo.getName()  + " ");
                System.out.print("Ex. Path: " + gp_foo.getExecutablePath() + " ");
                System.out.print("PID: " + gp_foo.getPID() + " ");
                System.out.println("Status: " + gp_foo.getStatus());
            }
            
            List<ProcessWaitForFlag> foo = new ArrayList<>();
            foo.add(ProcessWaitForFlag.Start);
            
            ProcessWaitResult waitResult = gp.waitForArray(foo, time); // again, use a valid timeout
            if(waitResult == ProcessWaitResult.Start){
                System.out.println("Process Load finished");
            }
            
        }
I did not check the code for syntax error, so please forgive any mistakes. And of course, you'll most likely need to fix your imports
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Re: Error 0x80bb0005 while executing Process on Windows Gues

Post by Skalden »

Thank you for the fast Reply!

I changed the way you described it. Now the process seems to start, but the GuestProcess doens't seem to load completely, so there is no IE window, when I take the screenshot. It just seems to ignore the waitFor.
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

What is the process state after the waitFor()? Also, did you check if the process is running in the guest via the task manager?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

And of course, beware of the following known limitation:
User Manual wrote:Guest control. On Windows guests, a process lauched via the guest control execute support will not be able to display a graphical user interface unless the user account under which it is running is currently logged in and has a desktop session.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Re: Error 0x80bb0005 while executing Process on Windows Gues

Post by Skalden »

The VM is running in GUI Mode, so the Frontend is there. Im Loggind into the machine as the same user, as with the guest session.

After the waitFor it is in "Start".
The Taskmanager didn't show any new process
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

Try to run a ping command instead (with a valid ip) and see if the process start.
If yes, then the issue is with IE and the environment.
If no, then we need to dig further but later today for me.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Re: Error 0x80bb0005 while executing Process on Windows Gues

Post by Skalden »

I run the ping command. But it seems that the piping to the file does not work. And the gp.read method delivers something back, but i can't decode the byte arrays ad hoc.

But I had the Taskmanager open and there was definetly the PING.exe for the currently logged in user. So that worked (kind of)

Edit: The CodeSnippet I used to run the Ping command

Code: Select all

public static void ping(VirtualBoxManager mgr, IMachine machine, String adress) {
        ISession session = mgr.getSessionObject();
        machine.lockMachine(session, LockType.Shared);
        IConsole console = session.getConsole();
        IGuest guest = console.getGuest();
        Long time = 50000L;
        IGuestProcess gp = null;
        
        System.out.println("Logging into Guest System");
        
        IGuestSession gs = guest.createSession("IEUser", "Passw0rd!", "", "");
        
        System.out.println("Hoping to be accepted...");
        //gs.waitFor(1L, time);
        
        List<GuestSessionWaitForFlag> gswff = new ArrayList<>();
        gswff.add(GuestSessionWaitForFlag.Start);
        GuestSessionWaitResult result = gs.waitForArray(gswff, time);

        if(result == GuestSessionWaitResult.Start){
            System.out.println("Guest Session is " + gs.getStatus());
            System.out.println("Got accepted!");
            
            List<String> arguments = new ArrayList<>();
            arguments.add("C:\\Windows\\System32\\PING.exe");
            arguments.add(adress);
            //arguments.add("-t");
            //arguments.add(">");
            //arguments.add("C:\\file.txt");
            
            List<ProcessCreateFlag> pcf = new ArrayList<>();
            pcf.add(ProcessCreateFlag.WaitForProcessStartOnly);
            gp = gs.processCreate(null, arguments, null, pcf , time);
            
            System.out.println("Started the process");
            
            List<IGuestProcess> gps = new ArrayList<>();
            gps = gs.getProcesses();
            for(int i=0;i<gps.size();i++){
                IGuestProcess gp_foo = gps.get(i);
                System.out.print("Name: " + gp_foo.getName()  + " ");
                System.out.print("Ex. Path: " + gp_foo.getExecutablePath() + " ");
                System.out.print("PID: " + gp_foo.getPID() + " ");
                System.out.println("Status: " + gp_foo.getStatus());
            }
            
            List<ProcessWaitForFlag> pwff = new ArrayList<>();
            pwff.add(ProcessWaitForFlag.Start);
            
            ProcessWaitResult waitResult = gp.waitForArray(pwff, time);
            System.out.println(waitResult);
            if(waitResult == ProcessWaitResult.Start){
                String out = new String();
                while(gp.getStatus() == ProcessStatus.Started){
                    byte [] foo = gp.read(0L, 4096L, time);
                    out = out +  new String(foo);
                }
                System.out.println(out);
            }
        }
    }
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

Ok then that confims you need the right environment for IE to start it.
Guest session and guest processes are very bare "areas" where even regular environment variables are not set since it's not start with the desktop.
All these IE expectations will need to be fullfilled. It could also be a permissions problem...

So all in all, many things can go wrong. I personally can't help further with specific matters of GUI applications on Windows, lacking experience and knowledge.
But go with the pointers I gave you. I would expect it to be very similar to having a service or a scheduled task trying to interact with the desktop.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Re: Error 0x80bb0005 while executing Process on Windows Gues

Post by Skalden »

noteirak wrote:But go with the pointers I gave you. I would expect it to be very similar to having a service or a scheduled task trying to interact with the desktop.
That made the "click"!

I created a VBScript, what basically just started the IE with the Adress as parameter - and it worked fine! Thank you so much!
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: Error 0x80bb0005 while executing Process on Windows Gues

Post by noteirak »

Glad it clicked and you found a solution!
Could it be possible for you to share the VBScript to make this topic complete and be a reference in the future for people trying the same? Thank you!
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Skalden
Posts: 9
Joined: 18. Sep 2015, 07:49

Re: Error 0x80bb0005 while executing Process on Windows Gues

Post by Skalden »

To use the script, you execute the cscript command with the scriptname and the URL as parameter.

Code: Select all

Set objArgs = wscript.Arguments
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("iexplore.exe " & objArgs(0), 1)
WScript.sleep 10000
Post Reply