Launching InstallShield executable as different user throws STATUS_DLL_INIT_FAILED

0

I have written a wrapper for a couple of installers to deploy and log the output of a software package. I'm encountering an issue when actually calling the executables and it's stumping me!

In the last release we ran the installer and executables with the local system account without issue - because of the way the InstallShield executables were configured this time around (read: poorly1), I'm now having to call the processes using an Active Directory account with Administrator permissions (by hashing the password, decrypting it in the program and then calling it through a ProcessStartInfo object) like so:

private static void InstallPackage(string packagePath, string args = "")
        {
            log.DebugFormat("Entered 'InstallPackage' (packagePath: '{0}'; args: '{1}')", packagePath, args);
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = packagePath;
            psi.Arguments = args;
            psi.WindowStyle = ProcessWindowStyle.Hidden;

            if (UseNetworkCredentials)
            {
                log.Debug("Network credential flag detected - using hard-coded network credentials for installation...");

                psi.Domain = "FOOBAR";
                psi.UserName = "SRVC_PatchInstaller";
                psi.Password = NetworkCredsPassword;
                psi.UseShellExecute = false;

                log.DebugFormat("Network credentials configured successfully (DOMAIN: {0}, USERNAME: {1})", psi.Domain, psi.UserName);
            }

            log.Debug("Starting installer with specified arguments...");
            Process inst = Process.Start(psi);
            log.Debug("Waiting for installer exit...");

            while (inst.HasExited == false)
                System.Threading.Thread.Sleep(100);

            log.DebugFormat("Installer process completed (Exit code: '{0}', Exit code meaning: '{1}', Duration (secs): {2})", 
                inst.ExitCode, ExitCodeDescriptions.ContainsKey(inst.ExitCode) ? ExitCodeDescriptions[inst.ExitCode] : "UNKNOWN",
                (inst.ExitTime - inst.StartTime).TotalSeconds.ToString("0.##"));
            return;
        }

When this was tested on one of our laptops in head office this worked a treat but now in testing on a user's laptop, this is returning the following:

2018-01-30 14:39:33,591 InstallPackage [DEBUG] - Entered 'InstallPackage' (packagePath: 'C:\windows\ccmcache\4a\foo\bar.exe'; args: '/s /f1"C:\windows\ccmcache\4a\foo\bar.iss"')
2018-01-30 14:39:33,624 InstallPackage [DEBUG] - Network credential flag detected - using hard-coded network credentials for installation...
2018-01-30 14:39:33,626 InstallPackage [DEBUG] - Network credentials configured successfully (DOMAIN: FOOBAR, USERNAME: SRVC_PatchInstaller)
2018-01-30 14:39:33,626 InstallPackage [DEBUG] - Starting installer with specified arguments...
2018-01-30 14:39:38,005 InstallPackage [DEBUG] - Waiting for installer exit...
2018-01-30 14:39:38,109 InstallPackage [DEBUG] - Installer process completed (Exit code: '-1073741502', Exit code meaning: 'UNKNOWN', Duration (secs): 2.24)

Now, I did some Googling about this error code and found that the exit code was actually an NTSTATUS error 0xC0000142, otherwise known as "STATUS_DLL_INIT_FAILED". I also found these questions relating to the issue. What is causing this exception and how can I fix it?


1: The reason behind this is that the InstallShield executables are attempting to extract files to the C:\Users\USER_NAME\AppData\ folder. Since the LocalSystem account lacks this folder, the installer extracts the files to the C:\Windows\Temp folder but then doesn't look in the same folder later on which causes the installer to bomb out.

c#
asked on Stack Overflow Feb 1, 2018 by Fredulom • edited Feb 9, 2018 by Uwe Keim

1 Answer

0

I found what the issue is - the fault was down to SCCM attempting to install the software when no users had logged in. I believe that this error was thrown because user32.dll had not been initialised by the OS.

answered on Stack Overflow Feb 9, 2018 by Fredulom

User contributions licensed under CC BY-SA 3.0