我在重大升级时遇到了问题.安装程序包含一项服务,在升级时我得到一个弹出窗口,说明需要重新启动才能完成安装过程.
为了防止这种行为,我实际上只需要在执行RemoveExistingProducts(而不是InstallValidate)之前停止服务.
在MajorUpgrade放置后InstallInitialize和所述封装具有InstallPrivileges="elevated".
我有两个案例:
案例1:服务由ServiceInstallvia 安装
<Component Id="myservice_Service" Guid="*">
<File Id="myservice.exe" KeyPath="yes" Vital="yes"
Source="SourceDir\bin\myservice.exe"/>
<ServiceInstall Id="myservice_ServiceInstall" Type="ownProcess"
Vital="yes" Name="myservice" DisplayName="myservice Service"
Description="myservice Service" Start="auto" Account=".\LocalSystem"
ErrorControl="ignore" Interactive="no" Arguments="--run"/>
<ServiceControl Id="myservice_ServiceControl" Name="myservice" Wait="yes" Stop="uninstall"/>
</Component>
Run Code Online (Sandbox Code Playgroud)
在ServiceControl不停止服务之前InstallValidate被调用.即使说Stop ="both".所以弹出窗口出现了.请注意,安装程序不会启动该服务.
我发现的合理帖子(摘录):
案例2:服务由a安装CustomAction(有一些原因,为什么不做通过ServiceInstall).在这种情况下,我必须调用可执行文件来停止服务("myservice.exe --stop").为此,它变得棘手,因为由于ICE63,不允许调度CustomAction之前RemoveExistingProducts调用.那么,我怎么能实现这个呢?
到目前为止,我已阅读过以下帖子:
bootstrapper exe是没有选择的,因为我需要生成一个普通的MSI.
我在这里找到了类似的未解答的问题:Wix安装程序问题:为什么RestartManager将服务标记为RMCritical而不是RMService
如何在C中告诉嵌入式perl它的工作目录是什么?
它似乎设置为使用嵌入式perl的可执行文件的目录.在调用嵌入的perl之前从外部设置目录不会改变它的行为.
在实际脚本启动之前,可能会在"chdir"中弹出一个可能的解决方法,但我不喜欢这样.
我的代码在技术上看起来像这样:
PERL_SYS_INIT3(NULL, NULL, NULL);
my_perl = perl_alloc();
PERL_SET_CONTEXT(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
PERL_SET_CONTEXT(my_perl);
PL_perl_destruct_level = 1;
perl_construct(my_perl);
int argc = 2;
char** argv = new char*[argc];
argv[0] = new char[4096];
argv[0][0] = '\0';
argv[1] = scriptFileName;
PERL_SET_CONTEXT(my_perl);
perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
perl_run(my_perl)
PL_perl_destruct_level = 1;
PERL_SET_CONTEXT(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
my_perl = NULL;
Run Code Online (Sandbox Code Playgroud)
上面列出的代码在不同的线程中运行.也许有什么需要考虑的?
谢谢你的提示!
我遇到的问题是,在卸载(或升级)时,重新启动管理器抱怨某个文件正在使用中,因此强制重新启动:
RESTART MANAGER: Detected that application with id 7000, friendly name 'javaw.exe', of type RmCritical and status 1 holds file[s] in use.
RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
Run Code Online (Sandbox Code Playgroud)
RESTART MANAGER抱怨的服务是基于Java的服务。服务(此处称为myservice.exe)以递归方式启动java子进程:
myservice.exe-
运行
↳javaw.exe --someArguments↳someother.exe
--someArguments↳javaw.exe --someMoreArguments
服务定义的wix代码段:
<DirectoryRef Id="BINDIR">
<Component Id="myservice.exe" Guid="PUT-GUID-HERE">
<File Id="myservice.exe" KeyPath="yes" Vital="yes"
Source="SourceDir\bin\myservice.exe"/>
<ServiceInstall Id="MyService" Type="ownProcess"
Vital="yes" Name="MyService" DisplayName="My Service"
Description="My Service" Start="auto" Account=".\LocalSystem"
ErrorControl="normal" Interactive="no" Arguments="--run"/>
<ServiceControl Id="MyService" Name="MyService" Wait="yes" Remove="uninstall" Stop="uninstall" Start="install"/> …Run Code Online (Sandbox Code Playgroud)