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;
}Code: Select all
C:\Users\MeMyself\AppData\RoamingCode: 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\RoamingI suggest to consider this a bug.