installshield中执行批处理

来源:互联网 发布:软件总体技术方案 编辑:程序博客网 时间:2024/04/18 22:14

可以在basic MSI 里添加脚本,安装时运行函数为MyINSTALLFun:export prototype MyINSTALLFun(HWND);

 

function MyINSTALLFun(hMSI)            STRING    svResult;      STRING    cmdline;begin                  if(FindFile(SystemFolder,"ServiceUSB.exe",svResult)=0) then                 cmdline="cmd /c install.bat";                     if (LaunchAppAndWait ("",cmdline, WAIT) < 0) then             MessageBox ("Unable to launch cmd ",SEVERE);                endif;              endif;                    end;


同理 在卸载时运行函数:

function MyFunction(hMSI)       // To Do:  Declare local variables.      STRING    svResult;     STRING    cmdline;     begin                   if(FindFile(SystemFolder,"ServiceUSB.exe",svResult)=0) then                 cmdline="cmd /c install.bat uninstall";                     if (LaunchAppAndWait ("",cmdline, WAIT) < 0) then             MessageBox ("Unable to launch cmd ",SEVERE);         endif;                 endif;       if(FindFile(SystemFolder,"install.bat",svResult)=0) then            DeleteFile(SystemFolder^"install.bat");              endif;      if(FindFile(SystemFolder,"ServiceUSB.exe",svResult)=0) then            DeleteFile(SystemFolder^"ServiceUSB.exe");              endif;                  if(FindFile(SystemFolder,"pkcs11.dll",svResult)=0) then            DeleteFile(SystemFolder^"pkcs11.dll");              endif;                    DeleteProgramFolder(INSTALLDIR);end;


另外如果设置环境变量:

设计环境变量  环境变量 可以从注册表中设置 用户变量的位置是 :HKEY_CURRENT_USER/Environment系统变量的位置是:HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/Environment function SetEnvironment()begin                RegDBSetDefaultRoot (HKEY_CURRENT_USER);        RegDBSetKeyValueEx ("Environment" , "JAVA_HOME" , REGDB_STRING_EXPAND , TARGETDIR+"//Java" , -1);          RegDBSetKeyValueEx ("Environment" , "CATALINA_HOME" , REGDB_STRING_EXPAND ,TARGETDIR+"//tomcat" , -1);        RegDBSetKeyValueEx ("Environment" ,"JRE_HOME" , REGDB_STRING_EXPAND ,TARGETDIR+"//Java//jre1.5.0_18" , -1);               //这个地方nzType千万不要直接用 REGDB_STRING    否则会编译出错 日        //if (RegDBGetKeyValueEx (szKey, "Path", nzType, svOld, nsize) < 0) then        //        MessageBox ("RegDBGetKeyValueEx failed.", SEVERE);        //        abort;         //endif;         // svNew=svOld+";"+TARGETDIR+"//Java//bin";              //RegDBSetKeyValueEx ("Environment" , "Path" , REGDB_STRING ,svNew , -1);                 end;


参考http://blog.csdn.net/liaomin416100569/article/details/6045930