我编写了一个简单的c#程序来自动执行签名文件的过程,但我无法让它工作。对不起,但我不是C#的专家(显然)!这是我的代码:
static void Main(string[]
// This progam makes it easy to remember the parameters that need to be passed to signtool and automates the process
if (args.Length < 3)
{
Console.WriteLine("Usage: SignFile FileToSign .pfxfile Password");
}
else
{
try
{
string signTool = "\"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\signtool.exe\"";
string fileToSign = args[0];
string pfxFile = args[1];
string password = args[2];
string commandLine = "/C " + signTool + " sign /f \"" + pfxFile + "\" /fd SHA256 /p "
+ password + @" /t http://timestamp.verisign.com/scripts/timestamp.dll " + fileToSign;
ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "cmd.exe";
System.IO.Directory.SetCurrentDirectory(".");
startInfo.Arguments = commandLine;
Process process = new Process();
startInfo.UseShellExecute = false;
process.StartInfo = startInfo;
process.Start();
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
throw;
}
}
}
当我运行它时,我得到'C:\ Program'不被识别为内部或外部命令。
我也尝试使用目录名的简短版本:
string signTool = "\"c:\\PROGRA~2\\MICROS~2\\Windows\\v7.0A\\Bin\\signtool.exe\"";
但是我得到了:
The filename, directory name, or volume label syntax is incorrect.
我可以说更多,但我想我会留下这么简单......