If the installer, which spawns the program, is running under a user, for that program, "Current user" is that user, ie. Administrator in your case.
You will have to explicitly escape out to a different user context, and unfortunately this involves getting the user to specify his password (at the very least). Otherwise you could have programs impersonating users all willy-nilly.
If you run your application with administrator privileges in Vista, then does it work?
You can also create a COM object with elevated privileges using this code:
HRESULT __stdcall CreateElevatedComObject(HWND hwnd, REFCLSID rclsid, REFIID riid, __out IUnknown ** ppv)
{
OSVERSIONINFO ver={sizeof(ver)};
if (GetVersionEx(&ver) && ver.dwMajorVersion > 5)
{
BIND_OPTS3 bo;
WCHAR wszCLSID[50];
WCHAR wszMonikerName[300];
if (StringFromGUID2(rclsid, wszCLSID, ELEMENTS(wszCLSID)))
{
HRESULT hr = StringCchPrintf(wszMonikerName,
ELEMENTS(wszMonikerName),
L"Elevation:Administrator!new:%s",
wszCLSID);
if (FAILED(hr))
return hr;
memset(&bo, 0, sizeof(bo));
bo.cbStruct = sizeof(bo);
bo.hwnd = hwnd;
bo.dwClassContext = CLSCTX_LOCAL_SERVER;
return CoGetObject(wszMonikerName, &bo, riid, (void **)ppv);
}
return E_FAIL;
}
else
return ::CoCreateInstance(rclsid,NULL,CLSCTX_ALL,riid,(void**)ppv);
}
Running under UAC, it will present an elevation dialog. The object will run out of process in dllhost (I think) but with full admin privileges.
Also look at the step by step guide for UAC in Vista.
Best Answer
Unfortunately, the Windows Installer does not provide a way to create a single package that can install per-machine and per-user but only prompt for UAC on the per-machine case. The issue is that the bit that can suppress the UAC prompt is stored in the SummaryInformation stream and is not modifiable while the package is executing.