如何通过InstallShield升级安装保留服务设置 [英] How to retain service settings through InstallShield upgrade install

查看:183
本文介绍了如何通过InstallShield升级安装保留服务设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IS2010中有一个InstallScript项目.它具有安装的少量服务.有些是C ++ exe,并且使用用于NT服务的InstallShield对象".其他是通过LaunchAppAndWait命令行调用使用 Java Service Wrapper 安装为服务的Java应用程序. .通过调用service.bat也可以将Tomcat作为服务安装.

I have an InstallScript project in IS2010. It has a handful of services that get installed. Some are C++ exes and use the "InstallShield Object for NT Services". Others are Java apps installed as services with Java Service Wrapper through LaunchAppAndWait command line calls. Tomcat is also being installed as a service through a call to its service.bat.

当安装程序在升级模式下运行时,将重新安装服务,并将设置(自动或手动启动,失败重启,登录帐户等)恢复为默认设置.

When the installer runs in upgrade mode, the services are reinstalled, and the settings (auto vs. manual startup, restart on fail, log-on account, etc.) are reverted to the defaults.

我想在文件传输之前保存服务设置,然后在之后重新填充服务设置,但是我一直没有找到一种很好的机制来做到这一点.如何保存和还原服务设置?

I would like to save the service settings before the file transfer and then repopulate them afterward, but I haven't been able to find a good mechanism to do this. How can I save and restore the service settings?

推荐答案

我通过从OnUpdateUIBefore的注册表中读取服务信息,将其存储在全局变量中,然后将该信息写回到OnUpdateUIAfter中的注册表中来完成此工作.

I got this working by reading the service information from the registry in OnUpdateUIBefore, storing it in a global variable, and writing the information back to the registry in OnUpdateUIAfter.

代码:

export prototype void LoadServiceSettings();
function void LoadServiceSettings()
number i, nResult;
string sServiceNameArray(11), sRegKey, sTemp;
BOOL bEntryFound;
begin
PopulateServiceNameList(sServiceNameArray);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//write service start values to the registry
for i = 0 to 10
    if (ServiceExistsService(sServiceNameArray(i))) then
        sRegKey = "SYSTEM\\CurrentControlSet\\Services\\" + sServiceNameArray(i);
        nResult = RegDBSetKeyValueEx(sRegKey, "Start", REGDB_NUMBER, sServiceSettings(i), -1);
        if(nResult < 0) then
            MessageBox ("Unable to save service settings: " + sServiceNameArray(i) + ".", SEVERE);
        endif;
    endif;
endfor;
RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); //set back to default
end;

export prototype void SaveServiceSettings();
function void SaveServiceSettings()
number i, nType, nSize, nResult;
string sServiceNameArray(11), sRegKey, sKeyValue;
begin
PopulateServiceNameList(sServiceNameArray);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
for i = 0 to 10
    if (ServiceExistsService(sServiceNameArray(i))) then
        //get service start values from registry
        sRegKey = "SYSTEM\\CurrentControlSet\\Services\\" + sServiceNameArray(i);
        nResult = RegDBGetKeyValueEx(sRegKey, "Start", nType, sKeyValue, nSize);
        if(nResult < 0) then
            MessageBox ("Unable to save service settings: " + sServiceNameArray(i) + ".", SEVERE);
        endif;
        sServiceSettings(i) = sKeyValue;
    endif;
endfor;
RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); //set back to default
end;

这篇关于如何通过InstallShield升级安装保留服务设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆