WindowsIdentity.GetCurrent () returns SYSTEM on startup from custom action

I have a setup project (running on Windows 7) that triggers a custom action in commit that launches the application I just installed. While running this app, I have a method that checks the current username to do some authentication. When run from this custom action, I get "NTAUTHORITY \ SYSTEM" instead of "DOMAIN \ USER"

Update: This link from the accepted answer solved my problem:

How to customize MSI in Visual Studio setup / deployment project?

+2


a source to share


2 answers


You should probably read the value of the USERNAME

MSI property :

string username = Session.Property("USERNAME");

      

The above will work in immediate execution mode; however, in deferred mode, you explicitly need to pass the username using the property CustomActionData

to your custom action. See here for more details:

Tip: MSI Properties and Deferred Execution



UPDATE: . If you want to run the installed application after the installation is complete, you may prefer the approach described in this article:

Launching the application after installation with Visual Studio 2005

or use Aaron Stebner script to change your MSI:

How to customize MSI in Visual Studio setup / deployment project?

+3


a source


Below is the code I used in my Installer class as custom actions. This will return the currently logged in user, not "NTAUTHORITY \ SYSTEM"



    IdentityReference identity = new System.Security.Principal.NTAccount(Environment.GetEnvironmentVariable("USERDOMAIN") + "\\" + Environment.GetEnvironmentVariable("USERNAME"))

      

0


a source







All Articles