Changeset 788


Ignore:
Timestamp:
12/11/2008 12:15:36 PM (5 years ago)
Author:
lowjoel
Message:

Show a helpful message whenever Eraser tries to communicate with another instance of higher privileges (e.g., when a non-elevated process is communicating with an elevated process)

Location:
branches/eraser6/Eraser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Eraser/Program.cs

    r786 r788  
    319319 
    320320                    byte[] buffer = new byte[commandLineStr.Length]; 
    321                     int count = Encoding.UTF8.GetBytes(commandLineStr.ToString(),0, 
     321                    int count = Encoding.UTF8.GetBytes(commandLineStr.ToString(), 0, 
    322322                        commandLineStr.Length, buffer, 0); 
    323323                    client.Write(buffer, 0, buffer.Length); 
     324                } 
     325                catch (UnauthorizedAccessException) 
     326                { 
     327                    //We can't connect to the pipe because the other instance of Eraser 
     328                    //is running with higher privileges than this instance. Tell the 
     329                    //user this is the case and show him how to resolve the issue. 
     330                    MessageBox.Show(S._("Another instance of Eraser is already running but it is " + 
     331                        "running with higher privileges than this instance of Eraser.\n\n" + 
     332                        "Eraser will now exit."), S._("Eraser"), MessageBoxButtons.OK, 
     333                        MessageBoxIcon.Information); 
    324334                } 
    325335                catch (TimeoutException) 
     
    10961106 
    10971107            //Send the task out. 
    1098             using (Program.eraserClient = new RemoteExecutorClient()) 
    1099             { 
    1100                 if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 
    1101                 { 
    1102                     //The client cannot connect to the server. This probably means 
    1103                     //that the server process isn't running. Start an instance. 
    1104                     Process eraserInstance = Process.Start( 
    1105                         Assembly.GetExecutingAssembly().Location, "--quiet"); 
    1106                     eraserInstance.WaitForInputIdle(); 
    1107  
     1108            try 
     1109            { 
     1110                using (Program.eraserClient = new RemoteExecutorClient()) 
     1111                { 
    11081112                    if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 
    1109                         throw new Exception("Eraser cannot connect to the running " + 
    1110                             "instance for erasures."); 
    1111                 } 
    1112  
    1113                 Program.eraserClient.Run(); 
    1114                 Program.eraserClient.AddTask(ref task); 
     1113                    { 
     1114                        //The client cannot connect to the server. This probably means 
     1115                        //that the server process isn't running. Start an instance. 
     1116                        Process eraserInstance = Process.Start( 
     1117                            Assembly.GetExecutingAssembly().Location, "--quiet"); 
     1118                        eraserInstance.WaitForInputIdle(); 
     1119 
     1120                        if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 
     1121                            throw new Exception("Eraser cannot connect to the running " + 
     1122                                "instance for erasures."); 
     1123                    } 
     1124 
     1125                    Program.eraserClient.Run(); 
     1126                    Program.eraserClient.AddTask(ref task); 
     1127                } 
     1128            } 
     1129            catch (UnauthorizedAccessException e) 
     1130            { 
     1131                //We can't connect to the pipe because the other instance of Eraser 
     1132                //is running with higher privileges than this instance. 
     1133                throw new UnauthorizedAccessException("Another instance of Eraser " + 
     1134                    "is already running but it is running with higher privileges than " + 
     1135                    "this instance of Eraser. Tasks cannot be added in this manner.\n\n" + 
     1136                    "Close the running instance of Eraser and start it again without " + 
     1137                    "administrator privileges, or run the command again as an administrator", 
     1138                    e); 
    11151139            } 
    11161140        } 
  • branches/eraser6/Eraser/Strings.NL.resx

    r785 r788  
    151151    <value>(Untranslated)</value> 
    152152  </data> 
     153  <data name="Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit." xml:space="preserve"> 
     154    <value>(Untranslated)</value> 
     155  </data> 
    153156  <data name="{0} out of {1}" xml:space="preserve"> 
    154157    <value>{0} van {1}</value> 
  • branches/eraser6/Eraser/Strings.en.resx

    r785 r788  
    151151    <value>Could not load the setting {0} for plugin {1}. The setting has been lost.</value> 
    152152  </data> 
     153  <data name="Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit." xml:space="preserve"> 
     154    <value>Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit.</value> 
     155  </data> 
    153156  <data name="{0} out of {1}" xml:space="preserve"> 
    154157    <value>{0} out of {1}</value> 
  • branches/eraser6/Eraser/Strings.resx

    r785 r788  
    151151    <value>Could not load the setting {0} for plugin {1}. The setting has been lost.</value> 
    152152  </data> 
     153  <data name="Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit." xml:space="preserve"> 
     154    <value>Another instance of Eraser is already running but it is running with higher privileges than this instance of Eraser.\n\nEraser will now exit.</value> 
     155  </data> 
    153156  <data name="{0} out of {1}" xml:space="preserve"> 
    154157    <value>{0} out of {1}</value> 
Note: See TracChangeset for help on using the changeset viewer.