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

ISDev 7.02, Type 1 Custom Action in the Execute Se


1 reply to this topic

raycook

raycook
  • Members
  • 1 posts

Posted 26 April 2002 - 20:46

While using Installshield Developer 7.02, I have run into a rather interesting problem with a Type 1 custom action being run during the Installation Execute Sequence. The custom action in question is a simple method for killing any process running on Windows  by its process name. The code works fine when called from a command line executable or if the function is called by a type 1 custom action that is located in the User Interface Sequence. An error only occurs if the custom action is placed in the Execute Sequence.  The following code snippet, used to get the current process token privilege settings under Windows NT and above, produces a return code of 1 – Incorrect Function:

AdjustTokenPrivileges(
           hToken,
           FALSE,
           &tp,
           sizeof(TOKEN_PRIVILEGES),
           &tpPrevious,
           &cbPrevious
           );

if (dwRetVal=GetLastError() != ERROR_SUCCESS){
   WriteToInstallLog("AdjustTokenPrivileges - SetPrivilege first pass failed");
    LogReturnError("AdjustTokenPrivileges", dwRetVal);
    return FALSE;
}

The code used to adjust the process token privileges is based on MSKB article Q131065. I am extremely puzzled by the error since the function works at the command line and if the custom action is placed in the User Interface Sequence. Any help would be appreciated.

Thanks,
Ray Cook
raycook@us.ibm.com

hteichert

hteichert
  • Members
  • 158 posts

Posted 29 April 2002 - 09:45

There's a big difference between running code on
A) the command line and during user interface sequence and
B) running the same code in execute sequence.
During A) your code is running as the currently logged on user. In B) you're running as local system.
I never tried, but it might be that local system doesn't have the required privileges to run your AdjustTokenPrivileges request. In MSs platform SDK doku about AdjustTokenPrivileges you can read that "Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access".
Some examples from MS (like in Q136867) contain a check with OpenProcessToken if the current process has got the privilege to do the requested action ...
h.teichert-ott