[英]How can I make a c# command line application runnable in cmd.exe with installer?
[英]How to call cmd from C# application to generate nsis installer?
我試圖從C#應用程序調用命令提示符,然后命令提示符將運行一個參數以生成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#應用程序時,它不會生成安裝程序。 第一次,我認為string參數是錯誤的。 因此,我打開了一個新的命令提示符,並嘗試直接運行該參數,它可以工作。
您知道我的代碼有什么問題嗎?
為什么不直接啟動makensis.exe?
startInfo.FileName = @"C:\Program Files (x86)\NSIS\makensis.exe";
startInfo.Arguments = @"Z:\Project\BuildArea\workspace\installer\Setup_PRO.nsi";
process.StartInfo = startInfo;
process.Start();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.