ae做网站导航,住房和城乡建设部建造师网站,深圳外贸公司排名,开网店0基础教程可以通过cmd命令行来执行#xff0c;也可以通过代码来执行#xff0c;一般都需要管理员权限运行
代码 /// summary/// 静默安装/// /summary/// param namefileName安装文件路径/param/// param namearguments…可以通过cmd命令行来执行也可以通过代码来执行一般都需要管理员权限运行
代码 /// summary/// 静默安装/// /summary/// param namefileName安装文件路径/param/// param namearguments安装参数/param/// param nameisRunas是否以管理员权限运行/param/// returns/returnspublic static void SilentInstall(string fileName, string arguments, bool isRunas true, bool isCreateNoWindow false){Process processSetup new Process();processSetup.StartInfo.FileName fileName;if (isCreateNoWindow)processSetup.StartInfo.CreateNoWindow true;processSetup.StartInfo.Arguments arguments;processSetup.EnableRaisingEvents true;if (isRunas)processSetup.StartInfo.Verb runas;processSetup.Exited delegate { };processSetup.Start();processSetup.WaitForExit();var exitCode processSetup.ExitCode;processSetup.Close();}
例子
//软件安装
SilentInstall(C:\Test.msi, /quiet /n);//SQL SERVER安装
string saPwd 123;
string arguments $/q /ACTIONInstall /FEATURESSQLENGINE, REPLICATION, SNAC_SDK /INSTANCENAMESQLExpress /SECURITYMODESQL /SAPWD{saPwd} /IACCEPTSQLSERVERLICENSETERMS /UpdateEnabledFalse;
SilentInstall(file, arguments);
卸载程序
SilentInstall(msiexec.exe, $ /quiet /n /uninstall {testProductCode});
ProductCode为安装程序的ProductCode属性值 参考
静默安装_weixin_30741653的博客-CSDN博客
C#卸载软件 msiexec安装参数详解 - 爱码网
Installshield之静默安装_setup.iss_Blue_sky90的博客-CSDN博客
SQLserver静默安装命令行安装_Dan淡淡的心的博客-CSDN博客