Page 1 of 1

Terminate Install Under SYSTEM Account

Posted: Fri Oct 21, 2016 8:22 am
by Sheri_Steeves
Hello,

Is there any method from inside InstallAware that I can test if my install is running under the SYSTEM account? I need to terminate one of my installs when run in this environment.

I know about the Get System Setting Logged on User Name - the problem is that the SYSTEM name is locale specific. On an English O/S it is SYSTEM, and on a French system it is SYSTÈME. Is there a way to ask "Are you SYSTEM"? Or get the Well-Known SID (S-1-5-18)?

Right now my only approach is to write a C# console exe that queries that information for me using System.Security.Principal.WindowsIdentity.GetCurrent().IsSystem and to include that in my Support files and call it from inside IA.

Is there is a simpler way to do this from inside IA?

Thanks,

Sheri

Re: Terminate Install Under SYSTEM Account

Posted: Fri Oct 21, 2016 12:14 pm
by FrancescoT
Dear Sheri,

I suppose that you are already using the best solution :D

Regards

Re: Terminate Install Under SYSTEM Account

Posted: Fri Oct 28, 2016 9:40 am
by Sheri_Steeves
Francesco,

Thanks for confirming; I just wanted to make sure I wasn't missing anything obvious.

For reference for any other users who may need to do the same thing, I created a C# console app to test this using the following mainline code:

Code: Select all

static int Main(string[] args)
{
    int result = 0;
    using (var identity = System.Security.Principal.WindowsIdentity.GetCurrent())
    {
        if (identity.IsSystem)
        {
            result = 1;
        }
   }
   Console.Write(result.ToString());   
   return result;
}


Sheri

Re: Terminate Install Under SYSTEM Account

Posted: Mon Oct 31, 2016 12:25 pm
by FrancescoT
Thanks for sharing :D !

Regards