1
我想从C#应用程序调用命令提示符,然后命令提示符将运行一个参数来生成一个nsis安装程序。如何从C#应用程序调用cmd来生成nsis安装程序?
因此,这是生成安装程序的C#应用程序内的功能:
private bool GenerateInstaller(string pStrVersion)
{
bool IsSuccess = false;
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
System.Diagnostics.Debug.WriteLine("Installer version: " + pStrVersion);
if(pStrVersion == "PRO")
{
startInfo.Arguments = @"""C:\Program Files (x86)\NSIS\makensis.exe"" ""Z:\Project\BuildArea\workspace\installer\Setup_PRO.nsi""";
System.Diagnostics.Debug.WriteLine("argument: " + startInfo.Arguments);
process.StartInfo = startInfo;
process.Start();
IsSuccess = true;
}
else
{
startInfo.Arguments = @"""C:\Program Files (x86)\NSIS\makensis.exe"" ""Z:\Project\BuildArea\workspace\installer\Setup_STD.nsi""";
System.Diagnostics.Debug.WriteLine("argument: " + startInfo.Arguments);
process.StartInfo = startInfo;
process.Start();
IsSuccess = true;
}
return IsSuccess;
}
问题是,当我尝试运行C#应用程序,它不会生成安装程序。 我第一次认为字符串参数是错误的。所以,我打开了一个新的命令提示符,并尝试直接运行参数并且它可以工作。
你知道我的代码有什么问题吗?