Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Custom Action and AlwaysInstallElevated


4 replies to this topic

MichaelAllen

MichaelAllen
  • Members
  • 4 posts

Posted 13 May 2004 - 16:04

I have created an install that must be installed on a per machine basis. Thus we require that AlwaysInstallElevated be set for HKCU HKLM.
The problem arises in that I have a Custom Action (type 1) that attempts to set a registry value HKLM\Software\Microsoft\Windows NT\Winlogon\Userint and it always returns with access denied.

nReturn = RegOpenKeyEx(hKey, KeyPath, 0, KEY_WRITE , &hOpenKey);

if(nReturn == ERROR_FILE_NOT_FOUND )
{
DWORD dummy;
nReturn = RegCreateKeyEx( hKey, KeyPath, 0, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_WRITE, lpSecurityAttributes, &hOpenKey, &dummy);
}

if(nReturn == ERROR_SUCCESS)
{
// Set Registry to input
nReturn = RegSetValueEx( hOpenKey, Value, 0, nType, (BYTE*)pDataBuf, nSize );

RegCloseKey( hOpenKey );
}


Am i mis interputing the use of AlwaysInstallElevated ??

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 14 May 2004 - 10:27

Custom actions are default run in the context of the installing user. If you want a CA to run in the context of the Installer service, you need to set an extra flag in the CA type. Further, your CA must be listed in the InstallExecuteSequence table, it will never work when it's in the InstallUIExecute table.
Usually the Installer service is run by the LocalSystem account. This account does not have a HKCU, so make sure that you don't access the HKCU registry in that CA.

Why don't you use the registry table?

MichaelAllen

MichaelAllen
  • Members
  • 4 posts

Posted 14 May 2004 - 12:40

The reason I'm not using the registry table is that basically what I'm doing is modifying an existing value in the registry. In this case the \winlogon\UserInit key. So on uninstall I have to restore the orignal value. The easiest way I found of doing so was to get the orignal value save it in my own hive and write the new modified value. Then on uninstall simply resotore the saved value. Since the registry table doesn't have a conditional field this seems like the quickest way to do it.

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 May 2004 - 06:39

It would probably work if you require admin rights in your installer. This way only admins could install or uninstall and they should have access to the registry in question.
Regards
-Stein Åsmul

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 May 2004 - 06:40

Btw, I have never used elevated rights, but I did have a lot of problems with Installscript custom actions when I tried to make an install run elevated just for testing. Maybe if you use a VBScript to test if this works instead?
Regards
-Stein Åsmul