最近在做一个应用,Siliverlight5+C#制作的一个小客户端应用程序,但在实际使用过程中,经常有用户提示说SiliverLight安装不成功,很多原因是用户浏览器安装了360、搜狗等不同内核版本浏览器,导致SL不能正常添加应用程序快捷方式。经搜索,发现NSIS这个软件很好用,可以用它来解决这个问题。
步骤如下:首先要下载安装NSIS,下载地址:http://www.onlinedown.net/soft/22742.htm
1、在随便一个目录新建一个文件夹,我就命名为setup;
2、将最新的Siliverlight.exe Xap文件复制到该文件夹;
3、新建一个setup.nsi,内容如下:
Name "XXXX管理系统V2.1豪华版" OutFile "www.exe" InstallDir "$PROGRAMFILES\WWW" XPStyle on Function .onInit # the plugins dir is automatically deleted when the installer exits InitPluginsDir File /oname=$PLUGINSDIR\splash.bmp "splash.bmp" splash::show 1000 $PLUGINSDIR\splash Pop $0 FunctionEnd Section SetOutPath "$INSTDIR" SetOverwrite ifnewer File "Silverlight.exe" ExecWait "$INSTDIR\Silverlight.exe /q /doNotRequireDRMPrompt" File "WWW.xap" ExecWait '"$PROGRAMFILES\Microsoft Silverlight\sllauncher.exe" /install:"$INSTDIR\WWW.xap" /origin:"http://www.XXXX.com/WWW.xap" /shortcut:desktop+startmenu' SectionEnd
4、编译该脚本如下图