【发布时间】:2019-12-26 05:29:47
【问题描述】:
我想使用命令提示符自动刷新硬件。我检查了从 atprogram.exe 传递到命令提示符的字符串是否正确,现在已将其缩小到我的输出
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace AutoFlash
{
class Program
{
public static void Main(string[] args)
{
string atProgramLocaction = "\"C:\\Program Files
(x86)\\Atmel\\Studio\\7.0\\atbackend\\atprogram.exe\"";
string atProgramArgs = "-t atmelice -i swd -d DEVICENAME program
-f";
string fileLocation = "C\:\FILE.HEX";
string command = atProgramLocaction + " " + atProgramArgs + " " +
fileLocation;
Process AtmelCommand = new Process();
AtmelCommand.StartInfo.FileName = "cmd.exe";
AtmelCommand.StartInfo.Arguments = command;
AtmelCommand.StartInfo.RedirectStandardInput = true;
AtmelCommand.StartInfo.UseShellExecute = false;
AtmelCommand.StartInfo.RedirectStandardOutput = true;
AtmelCommand.Start();
Console.WriteLine(AtmelCommand.StandardOutput.ReadToEnd());
AtmelCommand.WaitForExit();
}
}
}
理想情况下希望看到 atmel 命令行输出“Firmware check OK 编程成功完成”传递给 cmd.exe 并打印以向用户确认固件已成功刷新。当前发生的是弹出一个空白命令行窗口。任何帮助都将不胜感激!
【问题讨论】:
标签: c# command-line console-application pipeline atmelstudio