private static void ExecuteShellCmd(EcasAction a, EcasContext ctx) { string strCmd = EcasUtil.GetParamString(a.Parameters, 0); string strArgs = EcasUtil.GetParamString(a.Parameters, 1, true, true); bool bWait = EcasUtil.GetParamBool(a.Parameters, 2); uint uWindowStyle = EcasUtil.GetParamUInt(a.Parameters, 3); string strVerb = EcasUtil.GetParamString(a.Parameters, 4, true); if (string.IsNullOrEmpty(strCmd)) { return; } Process p = null; try { PwEntry pe = null; try { pe = Program.MainForm.GetSelectedEntry(false); } catch (Exception) { Debug.Assert(false); } strCmd = WinUtil.CompileUrl(strCmd, pe, true, null, false); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = strCmd; if (!string.IsNullOrEmpty(strArgs)) { psi.Arguments = strArgs; } bool bShEx = true; if (!string.IsNullOrEmpty(strVerb)) { } // Need ShellExecute else if ((uWindowStyle == IdWindowMin) || (uWindowStyle == IdWindowMax)) { } // Need ShellExecute else { string strCmdFlt = strCmd.TrimEnd(new char[] { '\"', '\'', ' ', '\t', '\r', '\n' }); if (strCmdFlt.EndsWith(".exe", StrUtil.CaseIgnoreCmp) || strCmdFlt.EndsWith(".com", StrUtil.CaseIgnoreCmp)) { bShEx = false; } } psi.UseShellExecute = bShEx; if (uWindowStyle == IdWindowHidden) { psi.CreateNoWindow = true; psi.WindowStyle = ProcessWindowStyle.Hidden; } else if (uWindowStyle == IdWindowMin) { psi.WindowStyle = ProcessWindowStyle.Minimized; } else if (uWindowStyle == IdWindowMax) { psi.WindowStyle = ProcessWindowStyle.Maximized; } if (!string.IsNullOrEmpty(strVerb)) { psi.Verb = strVerb; } p = NativeLib.StartProcessEx(psi); if ((p != null) && bWait) { Program.MainForm.UIBlockInteraction(true); MessageService.ExternalIncrementMessageCount(); try { p.WaitForExit(); } catch (Exception) { Debug.Assert(false); } MessageService.ExternalDecrementMessageCount(); Program.MainForm.UIBlockInteraction(false); } } catch (Exception ex) { throw new Exception(strCmd + MessageService.NewParagraph + ex.Message); } finally { try { if (p != null) { p.Dispose(); } } catch (Exception) { Debug.Assert(false); } } }