Link to home
Start Free TrialLog in
Avatar of OrenRozen
OrenRozenFlag for Israel

asked on

Win32Exception: Unknown error (0xffffffff) when trying to run process.start()

the following are lines I'm running in an application:
this code is running in a service. when the service is started using the  LSA (local system account) I get the following exception:
System.ComponentModel.Win32Exception: Unknown error (0xffffffff)
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at ePcontrol.FrmControlCommands.ControlTimer_Tick(Object sender, EventArgs e)
=================================
System.Collections.ListDictionaryInternal
=================================
Unknown error (0xffffffff)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

NO PROBLEM when running the service logged on using a user with domain admin credentials.
try
                        {
                            //Installing the service
                            ProcessStartInfo InstallService = new ProcessStartInfo(Application.StartupPath + "\\ePagntSv.exe", " -i");
                            InstallService.WindowStyle = ProcessWindowStyle.Hidden;
                            Process pInstallService = Process.Start(InstallService);
                            pInstallService.WaitForExit();
                            InstallService = null;
                        }
                        catch (Exception ex)
                        {
                            _DoneChecking = "Yes";

                            StreamWriter SaveEx = File.AppendText(Application.StartupPath + "\\ePcontrolEx.txt");
                            SaveEx.WriteLine(ex.GetBaseException());
                            SaveEx.WriteLine("=================================");
                            SaveEx.WriteLine(ex.Data);
                            SaveEx.WriteLine("=================================");
                            SaveEx.WriteLine(ex.Message);
                            SaveEx.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                            SaveEx.Flush();
                            SaveEx.Close();
                        }

Open in new window

Avatar of ricovox
ricovox
Flag of United States of America image

Try adding the following lines BEFORE Process.Start

InstallService.CreateNoWindow = True;
InstallService.UseShellExecute = False;
If that doesn't work, perhaps you can try to execute a different exe (such as calc.exe etc.) to see if this has to do with security restrictions on the exe you are trying to launch.
Avatar of OrenRozen

ASKER

Thanks for the help.

I'll be able to check only after the weekend.

I'd also appreciate if you'll explain why you think the following lines should work/
InstallService.CreateNoWindow = True;
InstallService.UseShellExecute = False;

I think its something to do with credentials because when I set the service to log on using a user with domain admins credentials, the application is working with no problem.
Its something with the LSA credentials but I don't know where.

I think that you are right about the credentials. And we might have more troubleshooting to do before this question is resolved.

The reason I suggested those two lines are the following:

//This makes sure that no UI is produced. Sometimes services that launch programs with a UI can cause errors if the service is not allowed to interact with the desktop. This is probably NOT that important, but is worth a try. However I believe launching the process as "Hidden" has the same effect.
InstallService.CreateNoWindow = True;


//This line causes the process to be started DIRECTLY from the exe you specify, instead of by using the shell. This will only matter if there are security restrictions against using the shell to launch files.
InstallService.UseShellExecute = False;

Like I said, it is possible that neither line will help. But we can at least safely and easily eliminate them as possible issues.

I think the more important test is trying to execute different exes to see if it is a permissions issue.
ASKER CERTIFIED SOLUTION
Avatar of OrenRozen
OrenRozen
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
no solution was provided.
a workaround was created