草庐IT

process_item

全部标签

c# - 如何从 ServiceController 确定 Windows.Diagnostics.Process

这是我的第一篇文章,所以让我先打个招呼吧!我正在编写一个Windows服务来监视同一台服务器上许多其他Windows服务的运行状态。我想扩展应用程序以打印服务的一些内存统计信息,但我无法弄清楚如何从特定的ServiceController对象映射到其关联的Diagnostics.Process对象,我认为我需要确定内存状态。我发现了如何从ServiceController映射到原始图像名称,但我正在监视的许多服务都是从同一图像启动的,因此这不足以确定进程。有谁知道如何从给定的ServiceController获取Process对象?也许通过确定服务的PID?或者是否有人对此问题有其他解

c# - Process.Start ("IEXPLORE.EXE") 在启动后立即触发 Exited 事件。为什么?

我在xp中安装IE8时遇到一个奇怪的问题。我试图在c#中使用System.Diagnostics.Process.Start方法启动IE。我需要捕获IE的退出事件并进行一些操作。但我最终遇到了一个相当奇怪的问题,即IE在启动后立即触发exited事件。这是示例代码ProcessobjProcess=Process.Start("IEXPLORE.EXE","http://google.com");if(objProcess!=null){objProcess.EnableRaisingEvents=true;objProcess.Exited+=newEventHandler(myPr

c# - "StandardOut has not been redirected or the process hasn' t started yet”在 C# 中读取控制台命令输出时

感谢@user2526830提供的代码。基于该代码,我在程序中添加了几行,因为我想读取SSH命令的输出。下面是我的代码,它在while行出错StandardOuthasnotbeenredirectedortheprocesshasn'tstartedyet.我想要实现的是,我想将ls的输出读入一个字符串。ProcessStartInfostartinfo=newProcessStartInfo();startinfo.FileName=@"f:\plink.exe";startinfo.Arguments="-sshabc@x.x.x.x-pwabc123";Processproce

c# - Process.Exited 并不总是触发

如果我运行以下代码:ProcessmyProcess=newSystem.Diagnostics.Process();myProcess.StartInfo.FileName="notepad.exe";myProcess.EnableRaisingEvents=true;myProcess.Exited+=newSystem.EventHandler(Process_OnExit);myProcess.Start();publicstaticvoidProcess_OnExit(objectsender,EventArgse){//Deletethefileonexit}当我退出记事

c# - "Items collection cannot be modified when the DataSource property is set."

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭11年前。通过表单将文件添加到txt文件的程序有这个问题,但这个问题没有说明Fstream的任何内容,所以我认为它不必处理它,但我不确定是什么这个问题的意思是。lstEmployees.Items.Add("Norecordsfound.");

c# - MVC 错误 : The model item passed into the dictionary is null

我只是想建立一个View,但我收到以下错误:System.InvalidOperationException:Themodelitempassedintothedictionaryisnull,butthisdictionaryrequiresanon-nullmodelitemoftype'System.DateTime现在,我知道为什么会出现这种情况,数据库中的特定字段是空值,但它应该是空值,因为这是稍后编辑的内容。这是我的代码:ActionpublicActionResultView(Int64?Id){ModelContainerctn=newModelContainer();

c# - 电子邮件删除附件后,错误 "The process cannot access the file because it is being used by another process."

我正在做一个电子邮件表单。电子邮件有附件,并在附加文件后发送电子邮件。接下来需要从服务器删除文件。当我试图获取文件时,它给了我主题错误。我什至在删除文件之前调用了GC.Collect(),但错误仍然存​​在。我删除文件的代码是:privatevoidDeleteFiles(DataTabledt){GC.Collect();String[]sAttachments=newString[dt.Rows.Count];try{sAttachments=newString[dt.Rows.Count];for(Int32J=0;J要将文件附加到电子邮件,我的代码是:oMess.Subject

c# - Process.StartInfo.Arguments 是否支持 UTF-8 字符串?

可以使用UTF-8字符串作为StartInfo的参数吗?我正在尝试将UTF-8(在本例中为日语字符串)作为控制台参数传递给应用程序。类似这样的东西(这只是一个例子!(cmd.exe将是一个自定义应用程序))varprocess=newSystem.Diagnostics.Process();process.StartInfo.Arguments="/K\"echoこれはテストです\"";process.StartInfo.FileName="cmd.exe";process.StartInfo.UseShellExecute=true;process.Start();process.W

c# - asp.net下的Process.Start()?

根据msdn:ASP.NETWebpageandservercontrolcodeexecutesinthecontextoftheASP.NETworkerprocessontheWebserver.IfyouusetheStartmethodinanASP.NETWebpageorservercontrol,thenewprocessexecutesontheWebserverwithrestrictedpermissions.Theprocessdoesnotstartinthesamecontextastheclientbrowser,anddoesnothaveaccesst

c# - 从 Windows 服务调用时,Process.Start 不起作用

在Windows8上,我正在运行一个Windows服务。该服务应该通过启动一个程序Process.Start(exePath);但是进程会立即退出——甚至Main过程中的第一行也不会执行。以前,在Windows7上的相同服务中运行相同进程时,一切正常。如何让它重新工作?如何从Windows服务正确启动进程? 最佳答案 找到解决方案。流程必须像这样开始:ProcessStartInfoinfo=newProcessStartInfo(exePath);info.CreateNoWindow=true;info.UseShellExec