我正在尝试学习C#如何使用streamReader读取和解析文本文件中的多行,然后使用PSExec处理每一行
在cocomand.txt内部有多行示例 c:/command1.cmd c:/command2.bat c:/command3.cmd
private static void calleachline()
{
string pathx = @"c:\cocomand.txt";
using (StreamReader reader = new StreamReader(new FileStream(pathx, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.ASCII))
{
while ((!reader.EndOfStream))
{
System.Diagnostics.Process cmd = new System.Diagnostics.Process();
cmd.StartInfo.FileName = @"psexec.exe";
cmd.StartInfo.Arguments = @"\\localhost";
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.Start();
if (!cmd.WaitForExit(cmd2))
{
ExecutePSKill(cmd);
}
else
{
//
}
}
}
试图从一些线程中了解,但是由于我缺乏知识,看来这仍然行不通