Index: /xmlTools/trunk/posUpdate/Program.cs
===================================================================
--- /xmlTools/trunk/posUpdate/Program.cs	(revision 744)
+++ /xmlTools/trunk/posUpdate/Program.cs	(revision 745)
@@ -11,13 +11,14 @@
     class Program
     {
-        public static readonly string toolsVersion = "0.8a";
+        public static readonly string toolsVersion = "0.8b";
+        private static appErrors lastError;
 
         public enum appErrors
         {
-            // 0-19 Errors with input parameters
-            ERROR_PARAMS = 0,
-            FILE_NOT_FOUND = 1,
-            ELEMENT_NOT_SPECIFIED=2,
-            ELEMENT_NOT_FOUND=3,
+            // 1-19 Errors with input parameters
+            ERROR_PARAMS = 1,
+            FILE_NOT_FOUND = 2,
+            ELEMENT_NOT_SPECIFIED=3,
+            ELEMENT_NOT_FOUND=4,
             // 20-199 General application errors
             BACKUPS_ALREADY_EXISTS=20,
@@ -36,12 +37,14 @@
             Console.Error.WriteLine("Error Code: "+(int)error);
             Console.Error.WriteLine(description);
-            
+
             if (exitApp)
             {
                 Environment.Exit(1);
             }
+
+            lastError = error;
         }
 
-        public static void Main(string[] args)
+        public static int Main(string[] args)
         {
             try
@@ -49,8 +52,10 @@
                 //We use a command parse library due to its advantages
                 CLAP.Parser.RunConsole<ParametersParser>(args);
+                return (int)lastError;
             }
             catch (Exception e)
             {
                 printAppError(appErrors.ERROR_PARAMS, "Error processing parameters:\n" + e.ToString());
+                return (int)appErrors.ERROR_PARAMS;
             }
         }
Index: /xmlTools/trunk/posUpdate/Util.cs
===================================================================
--- /xmlTools/trunk/posUpdate/Util.cs	(revision 744)
+++ /xmlTools/trunk/posUpdate/Util.cs	(revision 745)
@@ -149,4 +149,16 @@
             return source.IndexOf(sToSearch, StringComparison.OrdinalIgnoreCase) >= 0;
         }
+
+        // Thanks DarthDevilous for the regex! http://forums.thedailywtf.com/forums/t/2478.aspx
+        public static string[] stringToArgsArray(string args)
+        {
+            MatchCollection ms = Regex.Matches(args, "([^\" ]*(\"[^\"]*\")[^\" ]*)|[^\" ]+");
+            List<string> listArgs=new List<string>();
+            foreach (Match m in ms)
+            {
+                listArgs.Add(m.Value.Replace("\"","")); //remove quotes or it will cause an error
+            }
+            return listArgs.ToArray();
+        }
     }
 }
Index: /xmlTools/trunk/posUpdate/XmlPatch.cs
===================================================================
--- /xmlTools/trunk/posUpdate/XmlPatch.cs	(revision 744)
+++ /xmlTools/trunk/posUpdate/XmlPatch.cs	(revision 745)
@@ -285,9 +285,9 @@
 
                     // Filename already exists?
-                    if (command.IndexOf("filename:") != -1)
+                    if (Util.ContainsIgnoreCase(command,"filename:"))
                     {
                         paramType = "filename:";
                     }
-                    else if (command.IndexOf("filename=") != -1)
+                    else if (Util.ContainsIgnoreCase(command, "filename="))
                     {
                         paramType = "filename=";
@@ -305,5 +305,5 @@
                         if (endIdx == -1)
                         {
-                            endIdx = command.IndexOf("\"", startIdx); // or with quotes
+                            endIdx = command.IndexOf("\n", startIdx); // or with endline
                         }
                         string currFilename = command.Substring(startIdx, endIdx - startIdx);
@@ -318,7 +318,5 @@
                 }
 
-                command = command.Replace("\"", ""); // remove quotes
-
-                Program.Main(command.Split(' ')); // use the current process is more efficient than start a new one
+                Program.Main(Util.stringToArgsArray(command)); // use the current process is more efficient than start a new one
             }
             catch (Exception e)
Index: /xmlTools/trunk/posUpdate/xmlTools.csproj.user
===================================================================
--- /xmlTools/trunk/posUpdate/xmlTools.csproj.user	(revision 744)
+++ /xmlTools/trunk/posUpdate/xmlTools.csproj.user	(revision 745)
@@ -2,5 +2,5 @@
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
-    <StartArguments>replaceall -element:FirstLevel -value:0 -nobackups -filename:C:\Users\home\AppData\Local\Temp\oni_aei\installrun_temp-2013_03_26-01_55_52\level0_final\xml\%2a.xml</StartArguments>
+    <StartArguments>patchfile -filename:TRAM-knockdown.oni-patch</StartArguments>
   </PropertyGroup>
   <PropertyGroup>
