Пример #1
0
        private bool ExecuteCommandLine(string commandLine)
        {
            string Command;
            string Arguments;

            if (ExtractCommand(commandLine, out Command, out Arguments))
            {
                // Special processing for CD command
                if (Command.Equals("cd", StringComparison.OrdinalIgnoreCase))
                {
                    int    DummyIndex;
                    string FolderPath = DequoteString(Arguments, out DummyIndex);
                    if (!string.IsNullOrEmpty(FolderPath))
                    {
                        ITwoPanelTab TwoPanelTab = GetService(typeof(ITab)) as ITwoPanelTab;
                        if (TwoPanelTab != null)
                        {
                            try
                            {
                                // Convert FolderPath string to virtual folder object
                                IFileSystemManager FileSystemManager = (IFileSystemManager)GetService(typeof(IFileSystemManager));
                                TwoPanelTab.CurrentPanel.CurrentFolder =
                                    (IVirtualFolder)FileSystemManager.FromFullName(FolderPath, VirtualItemType.Folder, CurrentFolder);
                            }
                            catch (ArgumentException)
                            {
                                // Skip invalid FolderPath value
                                MessageDialog.Show(FindForm(), Resources.sInvalidPath, Resources.sCaptionWarning, MessageDialog.ButtonsOk, MessageBoxIcon.Warning);
                                return(false);
                            }
                        }
                    }
                    return(true);
                }

                // Try to start new process
                try
                {
                    ProcessStartInfo StartInfo = new ProcessStartInfo(Command, Arguments);

                    string CurrentDir = CurrentDirectory;
                    if (!string.IsNullOrEmpty(CurrentDir))
                    {
                        StartInfo.WorkingDirectory = CurrentDir;
                    }

                    Process.Start(StartInfo);
                    return(true);
                }
                catch (Win32Exception e)
                {
                    // Skip any start process error
                    MessageDialog.Show(FindForm(), e.Message, Resources.sCaptionWarning, MessageDialog.ButtonsOk, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            return(false);
        }