我有一个程序,利用第三方命令行工具生成日志。第三方将所有输出生成到STDOUT,用户必须使用“>test.txt”命令保存文件。
然而,该程序以某种方式只生成了一定量的报告,而不是整个报告。这可以通过使用以下命令进行测试
C:\Test\ftk\ripxp>ripxp.exe -r C:\test\ftk\ntuser.dat -d "C:\System Volume\_rest ore{BB12863B-2C77-46C9-BCDA-1810E52F1089}" -p runmru > C:\test\test05.txt
在命令行控制台上运行时可以正常工作,但在程序中只部分工作。
错误被缩小为参数错误或文件保存错误部分(streamReader)。因此,错误可能是由于未正确保存STDOUT造成的。
因此,请问能否提供相关代码?谢谢!
第三方工具(2008 H. Carvey)的参数:
代码:
然而,该程序以某种方式只生成了一定量的报告,而不是整个报告。这可以通过使用以下命令进行测试
C:\Test\ftk\ripxp>ripxp.exe -r C:\test\ftk\ntuser.dat -d "C:\System Volume\_rest ore{BB12863B-2C77-46C9-BCDA-1810E52F1089}" -p runmru > C:\test\test05.txt
在命令行控制台上运行时可以正常工作,但在程序中只部分工作。
错误被缩小为参数错误或文件保存错误部分(streamReader)。因此,错误可能是由于未正确保存STDOUT造成的。
因此,请问能否提供相关代码?谢谢!
第三方工具(2008 H. Carvey)的参数:
RipXP v.20081001 - CLI RegRipper tool
RipXP [-r Reg hive file] [-p plugin module][-d RP dir][-lgh]
Parse Windows Registry files, using either a single module from the plugins folder.
Then parse all corresponding hive files from the XP Restore Points (extracted from
image) using the same plugin.
-r Reg hive file...Registry hive file to parse
-g ................Guess the hive file (experimental)
-d RP directory....Path to the Restore Point directory
-p plugin module...use only this module
-l ................list all plugins
-h.................Help (print this information)
Ex: C:\>rip -g
C:\>rip -r d:\cases\ntuser.dat -d d:\cases\svi -p userassist
All output goes to STDOUT; use redirection (ie, > or >>) to output to a file.
copyright 2008 H. Carvey
代码:
代码:
static void Main(string[] args)
{
// Automatically finds folder that starts with _restore
DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\System Volume\");
DirectoryInfo restoreFolder = directoryInfo.GetDirectories().FirstOrDefault(d => d.Name.StartsWith("_restore"));
// Gets the folder name
String baka = restoreFolder.Name;
if (restoreFolder == null)
throw new DirectoryNotFoundException();
Process process = new Process();
process.StartInfo.FileName = @"C:\test\ftk\ripxp\ripxp.exe";
process.StartInfo.Arguments = @"-r C:\test\ftk\ntuser.dat -d C:\System Volume\" + restoreFolder.Name + " -p runmru";
process.StartInfo.CreateNoWindow = false;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
String text = @"-r C:\test\ftk\ntuser.dat -d C:\System Volume\" +restoreFolder.Name + " -p runmru";
Console.WriteLine(baka);
Console.WriteLine(text);
// Strangely the program only outputs the first section "-r C:\test\ftk\ntuser.dat" argument results.....
System.IO.StreamReader reader = process.StandardOutput;
String sRes = reader.ReadToEnd();
StreamWriter SW;
SW = File.CreateText(@"C:\test\test01.txt");
SW.WriteLine(sRes);
SW.Close();
Console.WriteLine("File Created Successfully");
reader.Close();
}
Console.WriteLine(text);
后面添加Console.Out.Flush();
,那么你能看到整行输出吗? - SwDevMan81