public void UpdateList() { combolist.Items.Clear(); // if (cbmsvs.Checked) foreach (object mope in Globe.Lib.fx.MSVSMACROS.vals.Keys) // { // combolist.Items.Add(string.Format("$({0})",mope)); // } // if (cbuser.Checked) foreach (object mope in Globe.Lib.fx.Constants) // { // if (mope is IConstant) // { // IConstant poo =(mope) as IConstant; // if (poo.Alias!=null) // { // if (poo.Alias!=string.Empty) combolist.Items.Add(string.Format("$({0})",poo.Alias)); // } // //this.combolist.Items.Add(string.Format("$({0})",mope)); // } // } if (cbsys.Checked) { StringDictionary sd = RunProcess.EnvVars("explorer.exe", @"c:\windows\"); foreach (DictionaryEntry de in sd) { combolist.Items.Add(string.Format("$({0})", de.Key)); } sd.Clear(); sd = null; } }
/// <summary> send either a file name or path.</summary> static public void ExploreHere(string lvs) { if (lvs == null) { return; } if (lvs == string.Empty) { return; } RunProcess RP; if (!CheckFile(lvs)) { RP = new RunProcess("Explorer.exe", "/e,/root," + lvs, @"C:\windows", false, true, false, false); RP.Start(); RP.Close(); RP.Dispose(); return; } if (CheckFile(lvs)) { RP = new RunProcess("Explorer.exe", "/e,/root,\"" + FileUtil.FInfo(lvs).FullName + "\" , /select,\"" + lvs + "\"", @"C:\windows", false, true, false, false); RP.Start(); RP.Close(); RP.Dispose(); } }
public void Dispose() { if (Disposed) { return; } try { if (!(RunProcess?.HasExited ?? true)) { RunProcess?.Kill(); } if (File.Exists(FilePath)) { File.Delete(FilePath); } Console.WriteLine("Deleted temp file {0}", FilePath); } catch (Exception exc) { Console.WriteLine(exc.Message); } Disposed = true; }
public String ShellAction(String command) { if (RunProcess.Run(command)) { return(JsonConstructor.SendMessage(true, "成功")); } else { return(JsonConstructor.SendMessage(false, "脚本不存在或执行失败")); } }
public TaskManagerViewModel(Action <ProcessPriorityClass?> selectRadio) { _selectRadio = selectRadio; ProcessList = new ObservableCollection <ProcessListItem>(Process.GetProcesses().Select(p => new ProcessListItem(p))); SelectedProcess = ProcessList[0]; PriorityChanged = new PriorityChanged(this); RefreshList = new RefreshList(this); DeleteProcess = new DeleteProcess(); RunProcess = new RunProcess(); UpdateSpeedChanged = new UpdateSpeedChanged(async(r) => { _refreshRate = r; await StartRefresh(); }); }
public static void PostRunTask() { if (string.IsNullOrEmpty(Settings.Default.PostRunTask)) { Log.Info("Post Run Task not defined, skipping..."); return; } if (!File.Exists(Settings.Default.PostRunTask)) { Log.Error(string.Format("Post Run Task {0} doesn't exist, skipping...", Settings.Default.PostRunTask)); return; } var runTask = new RunProcess(); runTask.Execute(Settings.Default.PostRunTask, null, true); }
public void Exit() { if (RunProcess != null && RunProcess.HasExited == false) { try { RunProcess.Kill(); RunProcess.Close(); } catch { } } SetListViewInfo("未运行"); IsRun = false; RunProcess = null; }
public static int RunExecutable(string ExeName, string Params, Stream StandardOut, Stream StandardError) { RunProcess myProc = new RunProcess(ExeName, Params, StandardOut, StandardError); return(myProc.RunStreams()); }
public static ProcessExitInfo RunExecutable(string ExeName, string Params, string WorkingDirectory) { RunProcess myProc = new RunProcess(ExeName, Params, WorkingDirectory); return(myProc.Run()); }
/// <summary> /// Runs an Executable and returns the output /// </summary> /// <param name="ExeName">The full path and name of the executable</param> /// <param name="Params">The parameters for the exe</param> /// <returns>string containing the STDOUT of the process</returns> public static ProcessExitInfo RunExecutable(string ExeName, string Params) { RunProcess myProc = new RunProcess(ExeName, Params); return(myProc.Run()); }
public override Task process(WatchedEvent @event) { return(Task.Run(() => RunProcess?.Invoke(@event))); }
private void ProcessReceivedMessageResponse(SocketAsyncEventArgs e, ResponseMessage message) { var token = (HostAsyncUserToken)e.UserToken; if (message.Response is IdentificationData) { var idata = (IdentificationData)message.Response; Logger.WriteStr(" * New client has connected: " + idata.deviceName); // ...create ClientData (if does not exist already) and add to token //... //TODO: for testing only: //Get IP information var msg = new RequestMessage { OpCode = (int)EOpCode.IpConfigData }; SendMessage(e, WoxalizerAdapter.SerializeToXml(msg, TypeResolving.AssemblyResolveHandler)); } else if (message.Response is IpConfigData) { var ipConf = (IpConfigData)message.Response; token.Data.IpConfig = ipConf; //store in "database" //TODO: move to another place var msg = new RequestMessage { OpCode = (int)EOpCode.RunProcess }; var exec = new RunProcess { RunId = HostAsyncUserToken.RunId, Cmd = "notepad.exe", Args = "", WorkDir = "c:\\", TimeOut = 180000, //ms Hidden = true }; msg.Request = exec; SendMessage(e, WoxalizerAdapter.SerializeToXml(msg, TypeResolving.AssemblyResolveHandler)); } else if (message.Response is RunCompletedStatus) { var status = (RunCompletedStatus)message.Response; if (status.ExitCode == 0) { Logger.WriteStr("Remote successfully executed"); } else if (status.ExitCode > 0) { Logger.WriteStr("Remote program executed with exit code: " + status.ExitCode + "and error message: \"" + status.ErrorMessage + "\""); } else { throw new ArgumentException("Invalid exit code of remote execution (" + status.ExitCode + ")"); } //... } else { Logger.WriteStr("WARNING: Recieved unkown response from " + token.Socket.RemoteEndPoint.ToString() + "!"); } }
public static SetupTask CreateFrom(XElement taskElement) { SetupTask result; switch (taskElement.Name.LocalName) { case "Group": result = new Composite(taskElement); break; case "ExtractArchive": result = new ExtractArchive(taskElement); break; case "TweakINI": result = new TweakINI(taskElement); break; case "CopyFile": result = new CopyFile(taskElement); break; case "Embedded": result = new Embedded(taskElement); break; case "Clean": result = new Clean(taskElement); break; case "CreateEmptyFolder": result = new CreateEmptyFolder(taskElement); break; case "RunProcess": result = new RunProcess(taskElement); break; case "DeleteFolder": result = new DeleteFolder(taskElement); break; case "DeleteFile": result = new DeleteFile(taskElement); break; case "MoveFolder": result = new MoveFolder(taskElement); break; case "EditFile": result = new EditFile(taskElement); break; case "Dummy": result = new Composite(); break; default: throw new NotSupportedException("Task type " + taskElement.Name.LocalName + " is not supported."); } result.xml = taskElement.ToString(); result.Id = taskElement.Attribute("Id")?.Value ?? Guid.NewGuid().ToString(); // this feels clunky, but that's fine I guess... result.WaitFor = result.WaitFor.Union(Program.Tokenize(taskElement.Attribute("WaitFor")?.Value)).ToImmutableArray(); return(result); }
static void Main(string[] args) { RunProcess runProcess = new RunProcess(); runProcess.Run(); }
protected virtual void OnRunProcess(EventArgs e) { RunProcess?.Invoke(this, e); }
public ActionResult ShowFinishForm(RunProcess process) { try { if (process.ProcessContext.CurrentFormId != null) { var formId = (Guid)process.ProcessContext.CurrentFormId; var form = process.FindFormById(formId); if (form == null) { var pm = GetPresentationProxy(); form = pm.Proxy.GetAnyForm(formId, GetLanguage()); } if (form is BizDetailForm) { if (process.ProcessContext.CurrentDocument != null) { if (process.ProcessContext.CurrentDocument.IsNew) { return(RedirectTo( new EditDocForm(this, formId, process.ProcessContext.CurrentDocument, process.ProcessContext.UserActions) { FormCaption = process.ProcessContext.FormCaption, ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions) })); } return (RedirectTo( new ShowDocForm(this, formId, process.ProcessContext.CurrentDocument, process.ProcessContext.UserActions) { FormCaption = process.ProcessContext.FormCaption, ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions) })); } if (process.ProcessContext.CurrentDocumentId != null) { return(RedirectTo( new ShowDocForm(this, formId, (Guid)process.ProcessContext.CurrentDocumentId, process.ProcessContext.UserActions) { FormCaption = process.ProcessContext.FormCaption, ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions) })); } return(RedirectTo( new ExceptionState(this, process.Previous, Process.ParameterError /*"Не все параметры заданы!"*/))); } if (form is BizTableForm) { return(RedirectTo(new ShowTableForm(this, formId, process.ProcessContext.FilterDocument, process.ProcessContext.UserActions) { FormCaption = process.ProcessContext.FormCaption, QueryDef = process.ProcessContext.CurrentQuery, ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions) })); } return(ThrowException(Form.FormTypeError /*"Ошибка в типе формы"*/)); } return(RedirectTo( new ExceptionState(this, process.Previous, Process.ParameterError /*"Не все параметры заданы!"*/))); } catch (Exception e) { return(RedirectTo(new ExceptionState(this, e.Message))); } }