コード例 #1
0
ファイル: LiveCapture.cs プロジェクト: tort32/renderdoc
        private void openNewWindow_Click(object sender, EventArgs e)
        {
            if (captures.SelectedItems.Count == 1)
            {
                var log = captures.SelectedItems[0].Tag as CaptureLog;

                var temppath = m_Core.TempLogFilename(log.exe);

                if (!log.local)
                {
                    MessageBox.Show("Can't open log in new instance with remote server in use", "Cannot open new instance",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    File.Copy(log.path, temppath);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Couldn't save log to temporary location" + Environment.NewLine + ex.ToString(), "Cannot save temporary log",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath, String.Format("--tempfile \"{0}\"", temppath));
                process.Start();
            }
        }
コード例 #2
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var proj = DTE.ActiveDocument.ProjectItem.ContainingProject;

            DTE.Solution.SolutionBuild.BuildProject(DTE.Solution.SolutionBuild.ActiveConfiguration.Name,
                                                    proj.UniqueName, true);

            var outputPath = GetOutputPath(proj);

            if (!File.Exists(outputPath))
            {
                return;
            }
            var dir = Directory.GetParent(outputPath).ToString();

            if (processId.HasValue)
            {
                try
                {
                    var p = Process.GetProcessById(processId.Value);
                    p.CloseMainWindow();
                    p.WaitForExit(5000);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Failed to kill previous powershell process.");
                    Debug.WriteLine(ex);
                }
            }

            try
            {
                var p = new System.Diagnostics.Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName         = @"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe",
                        WorkingDirectory = dir,
                        Arguments        = $"-NoExit -Command \"& {{Import-Module '{outputPath}'}}\""
                    }
                };
                p.Start();
                processId = p.Id;

                var dteProcess = DTE.Debugger.LocalProcesses.Cast <EnvDTE.Process>().FirstOrDefault(prop => prop.ProcessID == processId);

                if (dteProcess != null)
                {
                    dteProcess.Attach();
                    DTE.Debugger.CurrentProcess = dteProcess;
                }
            }
            catch (Exception ex)
            {
                ActivityLog.LogError("OpenForPSCmdlet", $@"Failed to launch powershell
{ex.Message}
{ex.StackTrace}");
            }
        }
コード例 #3
0
ファイル: Package.cs プロジェクト: taigacon/ironboard
        void IbApplication_OnOpenFile(string fullPath)
        {
            var p = new System.Diagnostics.Process();

            p.StartInfo.UseShellExecute = true;
            p.StartInfo.FileName        = fullPath;
            p.Start();
        }
コード例 #4
0
 public System.Diagnostics.Process GetGame()
 {
     System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessesByName(EDProgramName).FirstOrDefault();
     if (process == null)
     {
         Logger.LogMessage(String.Format("Can't find running {0}", EDProgramName));
         return(null);
     }
     return(process);
 }
コード例 #5
0
 private void LaunchGame()
 {
     try {
         System.Diagnostics.Process createGameProcess = new System.Diagnostics.Process();
         createGameProcess.StartInfo.FileName  = UserSettings.PlayerConfig.HunterPie.Launch.GamePath;
         createGameProcess.StartInfo.Arguments = UserSettings.PlayerConfig.HunterPie.Launch.LaunchArgs;
         createGameProcess.Start();
     } catch {
         Debugger.Error("Failed to launch Monster Hunter World. Common reasons for this error are:\n- Wrong file path;");
     }
 }
コード例 #6
0
        private bool StartUpdateProcess()
        {
            if (!File.Exists("Update.exe"))
            {
                return(false);
            }

            System.Diagnostics.Process UpdateProcess = new System.Diagnostics.Process();
            UpdateProcess.StartInfo.FileName  = "Update.exe";
            UpdateProcess.StartInfo.Arguments = $"version={HUNTERPIE_VERSION} branch={UserSettings.PlayerConfig.HunterPie.Update.Branch}";
            UpdateProcess.Start();
            return(true);
        }
コード例 #7
0
ファイル: VisualStudioIde.cs プロジェクト: rsumner33/PTVS
        /// <summary>
        /// Create a Visual Studio process.
        /// </summary>
        /// <param name="info">Startup information.</param>
        private void StartNewInstance(VsIdeStartupInfo startupInfo)
        {
            try
            {
                Debug.Assert(startupInfo != null);
                Debug.Assert(m_process == null, "VisualStudioIde.StartNewInstance: m_process should be null!");

                Process process = new Process();
                process.StartInfo.UseShellExecute = false;
                if (startupInfo.WorkingDirectory != null)
                {
                    process.StartInfo.WorkingDirectory = startupInfo.WorkingDirectory;
                }

                process.StartInfo.FileName = VsRegistry.GetVsLocation(startupInfo.RegistryHive);
                Debug.Assert(!string.IsNullOrEmpty(process.StartInfo.FileName));

                // Note that this needs to be partial (not $-terminated) as we partially match/replace.
                Regex versionRegex = new Regex(@"^[0-9]+\.[0-9]+");

                string hiveVersion = versionRegex.Match(startupInfo.RegistryHive).Value;
                string hiveSuffix  = versionRegex.Replace(startupInfo.RegistryHive, string.Empty);

                if (!string.IsNullOrEmpty(hiveSuffix))
                {
                    process.StartInfo.Arguments = "/RootSuffix " + hiveSuffix;
                }

                process.Exited += new EventHandler(ProcessExited);
                process.EnableRaisingEvents = true;

                if (!process.Start())
                {
                    throw new VsIdeTestHostException(Resources.FailedToStartVSProcess);
                }

                m_process = process;

                string progId = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", VisualStudioIde.BaseProgId, hiveVersion);
                m_dte = GetDteFromRot(progId, m_process.Id);
                if (m_dte == null)
                {
                    throw new VsIdeTestHostException(Resources.FailedToGetDte);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail("VsIde.StartNewInstance: " + ex.ToString());
                throw;
            }
        }
コード例 #8
0
        public static void Start(string fileName, string arguments, System.EventHandler exitHandler)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName  = fileName;
            p.StartInfo.Arguments = arguments;
            //p.SynchronizingObject = this;
            p.EnableRaisingEvents = true;
            p.Exited += (sender, e) => {
                EditorApplication.delayCall += () => {
                    exitHandler(sender, e);
                };
            };

            p.Start();
        }
コード例 #9
0
        public System.Diagnostics.Process LaunchProcess(string app, string arguments)
        {
            var sb      = new StringBuilder();
            var process = new System.Diagnostics.Process();

            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName               = app;
            process.StartInfo.Arguments              = arguments;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.OutputDataReceived              += (sender, args) => sb.Append(args.Data);
            process.Start();
            process.BeginOutputReadLine();
            return(process);
        }
コード例 #10
0
        private void openNewWindow_Click(object sender, EventArgs e)
        {
            if (captures.SelectedItems.Count == 1)
            {
                var log = captures.SelectedItems[0].Tag as CaptureLog;

                var temppath = m_Core.TempLogFilename(log.exe);

                File.Copy(log.localpath, temppath);

                var process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath, String.Format("--tempfile \"{0}\"", temppath));
                process.Start();
            }
        }
コード例 #11
0
 private void Init(Process process, Stream stream, UserCallBack callback, Encoding encoding, int bufferSize)
 {
     this.process      = process;
     this.stream       = stream;
     this.encoding     = encoding;
     this.userCallBack = callback;
     this.decoder      = encoding.GetDecoder();
     if (bufferSize < 0x80)
     {
         bufferSize = 0x80;
     }
     this.byteBuffer         = new byte[bufferSize];
     this._maxCharsPerBuffer = encoding.GetMaxCharCount(bufferSize);
     this.charBuffer         = new char[this._maxCharsPerBuffer];
     this.cancelOperation    = false;
     this.eofEvent           = new Thr::ManualResetEvent(false);
     this.sb = null;
     this.bLastCarriageReturn = false;
 }
コード例 #12
0
        private void KillProcess()
        {
            if (m_process != null)
            {
                // wait for the specified time for the IDE to exit.
                // If it hasn't, kill the process so we can proceed to the next test.
                Stopwatch sw = Stopwatch.StartNew();
                while (!m_process.HasExited && (sw.Elapsed < s_ideExitTimeout))
                {
                    System.Threading.Thread.Sleep(RegistrySettings.BaseSleepDuration);
                }

                if (!m_process.HasExited)
                {
                    m_process.Kill();
                }

                m_process = null;
            }
        }
コード例 #13
0
ファイル: LiveCapture.cs プロジェクト: Clever-Boy/renderdoc
        private void openNewWindow_Click(object sender, EventArgs e)
        {
            if (captures.SelectedItems.Count == 1)
            {
                var log = captures.SelectedItems[0].Tag as CaptureLog;

                var temppath = m_Core.TempLogFilename(log.exe);

                File.Copy(log.localpath, temppath);

                var process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath, String.Format("--tempfile \"{0}\"", temppath));
                process.Start();
            }
        }
コード例 #14
0
ファイル: LiveCapture.cs プロジェクト: Nexuapex/renderdoc
        private void openNewWindow_Click(object sender, EventArgs e)
        {
            if (captures.SelectedItems.Count == 1)
            {
                var log = captures.SelectedItems[0].Tag as CaptureLog;

                var temppath = m_Core.TempLogFilename(log.exe);

                if (!log.local)
                {
                    MessageBox.Show("Can't open log in new instance with remote server in use", "Cannot open new instance",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    File.Copy(log.path, temppath);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Couldn't save log to temporary location" + Environment.NewLine + ex.ToString(), "Cannot save temporary log",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath, String.Format("--tempfile \"{0}\"", temppath));
                process.Start();
            }
        }
コード例 #15
0
        // Create a DevEnv process
        private void StartNewInstance(VsIdeStartupInfo info)
        {
            Debug.Assert(info != null);
            Debug.Assert(m_process == null, "VisualStudioIde.StartNewInstance: m_process should be null!");

            if (string.IsNullOrEmpty(info.RegistryHive))
            {
                info.RegistryHive = VSRegistry.GetDefaultVersion();
                if (string.IsNullOrEmpty(info.RegistryHive))
                {
                    // Please no Debug.Assert. This is a valid case.
                    throw new VsIdeTestHostException(Resources.CannotFindVSInstallation(info.RegistryHive));
                }
            }

            Process process = new Process();
            process.StartInfo.UseShellExecute = false;
            if (info.WorkingDirectory != null)
            {
                process.StartInfo.WorkingDirectory = info.WorkingDirectory;
            }

            process.StartInfo.FileName = VSRegistry.GetVSLocation(info.RegistryHive);
            Debug.Assert(!string.IsNullOrEmpty(process.StartInfo.FileName));

            // Note that this needs to be partial (not $-terminated) as we partially match/replace.
            Regex versionRegex = new Regex(@"^[0-9]+\.[0-9]+");

            string hiveVersion = versionRegex.Match(info.RegistryHive).Value;
            string hiveSuffix = versionRegex.Replace(info.RegistryHive, string.Empty);

            if (!string.IsNullOrEmpty(hiveSuffix))
            {
                process.StartInfo.Arguments = "/RootSuffix " + hiveSuffix;
            }

            if (!string.IsNullOrEmpty(info.AdditionalCommandLineArguments))
            {
                if (!string.IsNullOrEmpty(process.StartInfo.Arguments))
                {
                    process.StartInfo.Arguments += " ";
                }
                process.StartInfo.Arguments += info.AdditionalCommandLineArguments;
            }

            process.Exited += new EventHandler(ProcessExited);
            process.EnableRaisingEvents = true;

            if (!process.Start())
            {
                throw new VsIdeTestHostException(Resources.FailedToStartVSProcess);
            }

            m_process = process;

            string progId = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", VisualStudioIde.BaseProgId, hiveVersion);
            m_dte = GetDteFromRot(progId, m_process.Id);
            Debug.Assert(m_dte != null);
        }
コード例 #16
0
        private void KillProcess()
        {
            if (m_process != null)
            {
                // wait for the specified time for the IDE to exit.  
                // If it hasn't, kill the process so we can proceed to the next test.
                Stopwatch sw = Stopwatch.StartNew();
                while (!m_process.HasExited && (sw.Elapsed < s_ideExitTimeout))
                {
                    System.Threading.Thread.Sleep(RegistrySettings.BaseSleepDuration);
                }

                if (!m_process.HasExited)
                {
                    m_process.Kill();
                }

                m_process = null;
            }
        }
コード例 #17
0
        // Create a DevEnv process
        private void StartNewInstance(VsIdeStartupInfo info)
        {
            Debug.Assert(info != null);
            Debug.Assert(m_process == null, "VisualStudioIde.StartNewInstance: m_process should be null!");

            if (string.IsNullOrEmpty(info.RegistryHive))
            {
                info.RegistryHive = VSRegistry.GetDefaultVersion();
                if (string.IsNullOrEmpty(info.RegistryHive))
                {
                    // Please no Debug.Assert. This is a valid case.
                    throw new VsIdeTestHostException(Resources.CannotFindVSInstallation(info.RegistryHive));
                }
            }

            Process process = new Process();

            process.StartInfo.UseShellExecute = false;
            if (info.WorkingDirectory != null)
            {
                process.StartInfo.WorkingDirectory = info.WorkingDirectory;
            }

            process.StartInfo.FileName = VSRegistry.GetVSLocation(info.RegistryHive);
            Debug.Assert(!string.IsNullOrEmpty(process.StartInfo.FileName));

            // Note that this needs to be partial (not $-terminated) as we partially match/replace.
            Regex versionRegex = new Regex(@"^[0-9]+\.[0-9]+");

            string hiveVersion = versionRegex.Match(info.RegistryHive).Value;
            string hiveSuffix  = versionRegex.Replace(info.RegistryHive, string.Empty);

            if (!string.IsNullOrEmpty(hiveSuffix))
            {
                process.StartInfo.Arguments = "/RootSuffix " + hiveSuffix;
            }

            if (!string.IsNullOrEmpty(info.AdditionalCommandLineArguments))
            {
                if (!string.IsNullOrEmpty(process.StartInfo.Arguments))
                {
                    process.StartInfo.Arguments += " ";
                }
                process.StartInfo.Arguments += info.AdditionalCommandLineArguments;
            }

            process.Exited += new EventHandler(ProcessExited);
            process.EnableRaisingEvents = true;

            if (!process.Start())
            {
                throw new VsIdeTestHostException(Resources.FailedToStartVSProcess);
            }

            m_process = process;

            string progId = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", VisualStudioIde.BaseProgId, hiveVersion);

            m_dte = GetDteFromRot(progId, m_process.Id);
            Debug.Assert(m_dte != null);
        }