WiX:尽管能够以 LocalSystem 的身份安装和启动它,但仍无法停止服务 [英] WiX: Can't stop service despite being able to install and start it as LocalSystem

查看:27
本文介绍了WiX:尽管能够以 LocalSystem 的身份安装和启动它,但仍无法停止服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的.wxs 文件

This is my .wxs file

特别是我设法以 LocalSystem 用户的身份安装了一个服务,并启动了它:

Particularly I managed to install a service as a LocalSystem user, and started it:

        <!-- Directory where [prey]/versions/[version] will be -->
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLLOCATION" Name="Prey">
        <Directory Id="VersionsDir" Name="versions">
          <Directory Id="VersionDir" Name="$(var.ProductVersion)">
            <Directory Id="BinDir" Name="bin">
              <Directory Id="BinWindowsDir" Name="windows">
                <Component Id="CronServiceExe"
                           Guid="ECC25B2A-FB2E-425A-92AD-DCF1D34204FF">
                  <File Id="file_8FF048AD40124B9F9C07126F2C14A765"
                        Checksum="yes"
                        KeyPath="yes"
                        Source="source-msi\versions\0.10.0\bin\windows\cronsvc.exe" />
                  <ServiceInstall Id="CronServiceInstaller"
                                  Type="ownProcess"
                                  Vital="yes"
                                  Name="CronService"
                                  DisplayName="Cron Service"
                                  Start="auto"
                                  Account="LocalSystem"
                                  ErrorControl="normal"
                                  Interactive="no">
                  </ServiceInstall>
                  <ServiceControl Id="StartService"
                                  Start="install"
                                  Stop="both"
                                  Remove="uninstall"
                                  Name="CronService"
                                  Wait="yes" />
                </Component>
                <Component Id="CronServiceDll"
                           Guid="75C4129B-C28A-45A8-9F06-CB496259FE7F">
                  <File Id="file_11D016207EA34826A20A52524A3A82BC"
                        Checksum="yes"
                        KeyPath="yes"
                        Source="source-msi\versions\0.10.0\bin\windows\Cronsvclib.dll" />
                </Component>
              </Directory>
            </Directory>
          </Directory>
        </Directory>
      </Directory>
    </Directory>

它运行良好.一切正常,除非我要卸载产品.因为尽管在 UAC 对话框中被问到我得到(屏幕截图),但安装程序坚持认为我没有停止服务的权限.

And it runs fine. Everything is OK, except when I get to uninstall the product. Because despite being asked in an UAC dialog I get (Screenshot), the installer insist that I don't have permissions to stop the service.

这是错误截图,内容如下:

Service 'Cron Service' (CronService) could not be stopped. Verify that you have sufficient privileges to stop system services.

而且,这是特定的日志(我正在使用 /L*v 选项卸载以获得详细日志).您可以在此要点中获取完整文件.

And, here is the specific logs (I'm uninstalling with /L*v option to get verbose logs). You can get the full file in this gist.

第 2220 - 2226 行

Lines 2220 - 2226

MSI (s) (90:80) [19:11:54:953]: Note: 1: 2205 2:  3: Icon 
MSI (s) (90:80) [19:11:54:953]: Note: 1: 2205 2:  3: TypeLib 
MSI (s) (90:80) [19:11:54:953]: Note: 1: 2727 2:  
MSI (s) (90:80) [19:11:54:973]: RESTART MANAGER: Detected that the service CronService will be stopped due to a service control action authored in the package before the files are updated. So, we will not attempt to stop this service using Restart Manager
MSI (s) (90:80) [19:11:54:973]: Note: 1: 2727 2:  
MSI (s) (90:80) [19:11:54:973]: Doing action: InstallInitialize
MSI (s) (90:80) [19:11:54:973]: Note: 1: 2205 2:  3: ActionText 
Action ended 19:11:54: InstallValidate. Return value 1.

第 4624 - 4635 行

Lines 4624 - 4635

MSI (s) (90:80) [19:11:57:196]: Executing op: ActionStart(Name=StopServices,Description=Stopping services,Template=Service: [1])
MSI (s) (90:80) [19:11:57:196]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (90:80) [19:11:57:196]: Executing op: ServiceControl(,Name=CronService,Action=2,Wait=1,)
MSI (s) (90:80) [19:12:27:239]: Note: 1: 2205 2:  3: Error 
MSI (s) (90:80) [19:12:27:239]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1921 
MSI (s) (90:80) [19:16:38:940]: Note: 1: 2205 2:  3: Error 
MSI (s) (90:80) [19:16:38:940]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709 
MSI (s) (90:80) [19:16:38:940]: Product: Prey Anti-theft -- Error 1921. Service 'Cron Service' (CronService) could not be stopped.  Verify that you have sufficient privileges to stop system services.
MSI (s) (90:80) [19:17:08:983]: Note: 1: 2205 2:  3: Error 
MSI (s) (90:80) [19:17:08:983]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1921 
MSI (c) (48:84) [19:12:27:239]: Font created.  Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg

鉴于所有这些信息.我推断我必须设法在某个地方以管理员身份启动我的 MSI.还是不行?

Given all that information. I infere that somewhere I have to manage to start my MSI as an administrator. Or not?

那是我的问题:

  1. 有没有办法将我的 .msi 安装程序设置为仅限管理员"的安装程序?(如果确实存在这种选择).

  1. Is there a way to set up my .msi installer as an "admin only" one? (If that choice does exist).

奇怪的是,我得到的所有帖子和谷歌搜索结果都是关于安装和启动服务的问题,而不是停止服务.所以我陷入了死胡同.

The weird thing is that all posts and google results I'm getting are about problems INSTALLING and STARTING the service, rather than STOPPING it. So I'm in a dead end.

拜托,所有的帮助都会非常有用和感激.

Please, all help will be very useful and appreciated.

推荐答案

该错误消息包括建议这是一个权限问题.这种情况很少发生,因为安装服务需要提升权限才能开始.无法停止服务通常就像服务没有足够快地响应停止请求一样简单.CronService 是否实现了服务接口来响应停止请求?MSI 和 Windows 都不会终止服务进程来停止它.

The error message includes the suggestion that it's a permissions problem. That's rarely the case, since installing services requires elevated permissions to begin with. Failure to stop a service is usually as simple as the service not responding to the stop request quickly enough. Does CronService implement the service interface to respond to stop requests? Neither MSI nor Windows will kill a service process to stop it.

这篇关于WiX:尽管能够以 LocalSystem 的身份安装和启动它,但仍无法停止服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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