private void Work(AppStartConfigElement appItem) { StartProcess(appItem); //string processName = Path.GetFileName(appItem.Path); //bool isProcessStarted = IsProcessStarted(processName, appItem.Arg); //if (!isProcessStarted) //{ // StartProcess(appItem); //} }
private void StartProcess(AppStartConfigElement appItem) { string workingDirectory = Path.GetDirectoryName(appItem.Path); string processName = Path.GetFileName(appItem.Path); LogingService.Write.ErrorFormat("Try to start: {0} {1}", processName, appItem.Arg); ProcessStartInfo psi = new ProcessStartInfo(appItem.Path, appItem.Arg); psi.WorkingDirectory = workingDirectory; psi.WindowStyle = ProcessWindowStyle.Normal; psi.ErrorDialog = true; psi.UseShellExecute = false; if (!string.IsNullOrWhiteSpace(appItem.UserName) && !string.IsNullOrWhiteSpace(appItem.Password)) { psi.UserName = appItem.UserName; psi.Password = appItem.Password.ToSecureString(); } Process.Start(psi); }