Incorrect user profile when using "guestcontrol execute"

Discussions about using Windows guests in VirtualBox.
Post Reply
Nox Metus
Posts: 14
Joined: 11. Aug 2010, 09:01
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Winows 7, Ubuntu

Incorrect user profile when using "guestcontrol execute"

Post by Nox Metus »

Imagine we have a Windows guest. No matter under which host. A program, which we are going to launch on the guest by means of "VBoxManage guestcontrol execute", queries the application data folder. For example, like this:

Code: Select all

  WCHAR path[MAX_PATH];
  HRESULT hRes = SHGetFolderPathW(0, CSIDL_APPDATA, 0, 0, path);

  if SUCCEEDED(hRes) {
    std::wcout << path << std::endl;
  } else {
    std::cout << "SHGetFolderPathW returned error ";
    std::cout << "0x" << std::hex << std::fixed << std::setw(8) << std::setfill('0') << hRes << std::endl;
    std::cout << "APPDATA = " << getenv("APPDATA") << std::endl;
  }
The normal output of the code above (in Vista and Windows 7) would be:

Code: Select all

C:\Users\MeMyself\AppData\Roaming
But if we run this program (let's say its name is shgetfolder.exe) from the host, the code will fail:

Code: Select all

C:\> VBoxManage --nologo guestcontrol execute "My VM" "c:\path\shgetfolder.exe" --username "MeMyself" --password "SuperPuperSecret" --wait-for stdout
SHGetFolderPathW returned error 0x80070005
APPDATA = C:\Windows\system32\config\systemprofile\AppData\Roaming
So as we can see, despite the program was ran under MeMyself user account, the environment for the process contains a wrong user profile path, which is in fact inaccessible to the user. This leads to errors in various applications. For example, svn command line client fails to start, saying “svn: Can't determine the user's config path”.

I suggest to consider this a bug.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Incorrect user profile when using "guestcontrol execute"

Post by Sasquatch »

Is the actual user logged on, or is the Guest sitting at the Welcome screen with nobody logged on? If that's the case, it's not a bug, it's a user error. It only works for the user that is currently logged on. No user logged on means System is in control.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Nox Metus
Posts: 14
Joined: 11. Aug 2010, 09:01
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Winows 7, Ubuntu

Re: Incorrect user profile when using "guestcontrol execute"

Post by Nox Metus »

Sasquatch wrote:Is the actual user logged on, or is the Guest sitting at the Welcome screen with nobody logged on? If that's the case, it's not a bug, it's a user error. It only works for the user that is currently logged on. No user logged on means System is in control.
In the example above the user MeMyself was logged in to the guest before the command

Code: Select all

VBoxManage --nologo guestcontrol execute "My VM" "c:\path\shgetfolder.exe" --username "MeMyself" --password "SuperPuperSecret" --wait-for stdout
was issued from the host.

And actually System (I guess you mean System account) is in control whether a user is logged in or not , since this is the account VBoxService.exe is running under. It is from this process the wrong environment was inherited. And if a process does not have a GUI, it should work fine with or without an actual user logged in.
Ich weiß nicht, was du sagest.
pentagonik
Oracle Corporation
Posts: 309
Joined: 19. May 2008, 16:09
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Too many to specify!
Contact:

Re: Incorrect user profile when using "guestcontrol execute"

Post by pentagonik »

Thanks for the report - the problem was reproduced and we're working on it.
Nox Metus
Posts: 14
Joined: 11. Aug 2010, 09:01
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Winows 7, Ubuntu

Re: Incorrect user profile when using "guestcontrol execute"

Post by Nox Metus »

pentagonik wrote:Thanks for the report - the problem was reproduced and we're working on it.
Hallelujah :)!
Kristian Karl
Posts: 2
Joined: 21. Dec 2010, 11:00
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows

Re: Incorrect user profile when using "guestcontrol execute"

Post by Kristian Karl »

This issue is still very much a problem.
I can reproduce this problem on a Linux Host, using VirtualBox version 4.2.4 (81684)

Does this problem have a ticket [trouble report] number?

/Kristian
Post Reply