basically I would like to write an application to perform this in command prompt:
sslist -H -R -h s234.ds.net /mobile > listofsnapshot.txt
then this is my code when i create a c# console application:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Search
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "sslist.exe";
p.StartInfo.Arguments = "-H -R -h s234.ds.net /mobile";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
string procOutput = p.StandardOutput.ReadToEnd();
开发者_运维百科 string procError = p.StandardError.ReadToEnd();
TextWriter outputlog = new StreamWriter("C:\\Work\\listofsnapshot.txt");
outputlog.Write(procOutput);
outputlog.Close();
}
}
}
why when i execute my console script, it just hangs there and not do anything?
sslist.exe
is probably waiting for input.
You can send it some input by setting p.StartInfo.RedirectStandardInput
to true
, then writing to p.StandardInput
.
精彩评论