主题并没有说太多,因为在一行中提出问题并不容易.我必须执行一些我从注册表中读取的程序.我必须从有人保存整个路径和参数的字段中读取.
我一直在使用System.Diagnostics.ProcessStartInfo设置程序的名称及其参数,但我发现了各种各样的参数,我必须解析这些参数以将进程可执行文件保存在一个字段中,将其参数保存在另一个字段中.
有没有办法按原样执行整个字符串?
我一直在使用C#System.Diagnostics.Process来监视命令行实用程序的输出.
我正在"内部"监视的进程启动第二个进程,并且一旦进行,我就不再接收进程对象的进一步输出.
令人沮丧的是,如果你使用cmd.exe(手动)执行相同的命令(我正在使用System.Diagnostics.Process对象启动),控制台将输出我需要在C#应用程序中看到的每一行!
但是,如果我(出于测试目的)使用System.Diagnostics.Process对象启动cmd.exe并运行该命令,它仍然会停止输出与之前相同的点(直接启动process1.exe); 在使用second.exe时.我认为这个测试会整合所有相关过程的输出,但事实并非如此.如何将所有这些输出都输入到我的C#应用程序中?
我想使用process.getprocesses()但它似乎不在我的诊断类中,为什么?!!!
对于以下代码,我得到了
System.ComponentModel.Win32Exception:找不到网络路径
有人可以帮忙吗?
PerformanceCounter pc = new PerformanceCounter("System",
"System Up Time");
pc.MachineName = "1.2.3.4";
//Normally starts with zero. do Next Value always.
pc.NextValue();
TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());
Response.Write("This system 1.2.3.4 has been up for " + ts.Days + " days " + ts.Hours + " hours, " + ts.Minutes + " and " + ts.Seconds +" seconds.");
Run Code Online (Sandbox Code Playgroud)
编辑:我尝试了机器名称,我仍然得到相同的错误!注意:1.2.3.4是一个样本值.
我们知道最终一切都是具有状态0和状态的晶体管1.
并且晶体管有时可能会损坏.
我们可以测试内存中是否有任何缺陷晶体管?
我认为它与硬件或其他任何东西相似.
使用WebClient类时,以编程方式跟踪完整原始HTTP请求的最佳方法是什么?
我发现这个程序(http://support.microsoft.com/kb/304655),其中i编译运行时的代码,它适用于使用参考代码,
using System;
Run Code Online (Sandbox Code Playgroud)
以下是在运行时编译代码的程序代码,
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "Out.exe";
Button ButtonObject = (Button)sender;
textBox2.Text = "";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
//Make sure we generate an EXE, not a DLL
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters, textBox1.Text);
if (results.Errors.Count > 0)
{
textBox2.ForeColor = Color.Red;
foreach (CompilerError CompErr in results.Errors)
{
textBox2.Text = textBox2.Text +
"Line number " + CompErr.Line +
", Error Number: " + …Run Code Online (Sandbox Code Playgroud) 我在我的客户端应用程序(用c#编写)上使用System.Diagnostics.Process.Start函数来调用URL并执行相应的操作.
string targetURL = "someurl";
System.Diagnostics.Process.Start(targetURL);
Run Code Online (Sandbox Code Playgroud)
运行URL会在服务器上进行某些更改并提供PLAIN_TEXT响应.现在问题在于调用此函数它打开Web浏览器并显示targetURL已调用.这有什么办法可以阻止吗?
我的意思是我希望更改发生但浏览器不应该打开.但应该做出改变.
我正在尝试使用 C# 监视另一个进程的内存。但是,Process.WorkingSet64 或 Process.PrivateMemorySize64 将输出的最大内存值为 4294967295。性能计数器也有同样的问题。
这是我的代码:
using System;
using System.Diagnostics;
namespace perfmon
{
class Program
{
static void Main(string[] args)
{
int pid;
if (int.TryParse(args[0], out pid))
{
var p = Process.GetProcessById(pid);
var ramCounter = new PerformanceCounter("Process", "Working Set", p.ProcessName);
Console.WriteLine($"ProcessName:{p.ProcessName}");
var ram = ramCounter.NextValue();
p.Refresh();
Console.WriteLine("WorkingSet64\tPrivateMemorySize64\tRam PC");
Console.WriteLine($"{p.WorkingSet64}\t{p.PrivateMemorySize64}\t\t{ram}");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在带有 .net 4.61 的 Windows Server 2012 R2 上运行。
输出:
C:\XXX\perfmon>perfmon.exe 15800
ProcessName:XXX.Windows.Services
WorkingSet64 PrivateMemorySize64 Ram PC
4294967295 4294967295 4.294967E+09
Run Code Online (Sandbox Code Playgroud)
进程的 Powershell 输出: …
在Windows 8.1上,您进入任务管理器并检查进程列表,有两个列表: - 一个用于"应用程序",它们是可见的前台应用程序 - 一个用于"后台进程",这是在后台运行的进程
我的最终目标是计算加载应用程序所需的时间.当应用程序仍在加载时,它将显示在"后台进程"中.但是,一旦加载,它就会显示在"应用"中.这将成为我对应用程序整理加载的标准.
我正在使用System.Diagnostics.Process对象来尝试完成此任务.但是,我正在努力想出一种方法来区分"后台进程"下的进程和"应用程序"下的进程.
有没有人知道如何区分这个?我查看了MSDN并尝试了不同的方法,但都没有成功.