installshield中如何执行批处理 还有设置环境变量

来源:互联网 发布:淘宝知网硕博系统查重 编辑:程序博客网 时间:2024/05/01 21:44

如何执行批处理

 

我们可以在事件中使用方法 来执行  installshield提供了该方法LaunchAppAndWait 来调用应用程序

 

 

//执行卸载脚本
function ExecuteUnstall()
string cmdline;        
begin   
              if(AskYesNo("您确定要卸载吗",YES)=NO)  then
                abort;             
               endif;
               cmdline="cmd /c /""+TARGETDIR+"//tools//uninstall.bat/"";  
               if (LaunchAppAndWait ("",cmdline, WAIT) < 0) then
                                MessageBox ("Unable to launch cmd "^cmdline^".",SEVERE);
               endif;    
               
              
             
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;

原创粉丝点击