WiX:注册应用程序以在Windows启动时自动运行不起作用

时间:2016-07-17 10:47:07

标签: wix

我试图在Windows启动时注册应用程序以自动运行。我无法理解它为什么不起作用?

我试图这样做:

<!-- Files.wxs -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension">   <Fragment>
      <DirectoryRef Id="INSTALLLOCATION" 
           FileSource="..\MyApp\bin\Release\">
          <Component Id ="ProductComponents" 
              DiskId="1"
              Guid="{482A3E9A-8FCA-44C6-96C5-F7B026DF85C4}">
              <File Id="MyApp.exe.config" Name="MyApp.exe.config"/>
              <File Id="MyApp.exe" Name="MyApp.exe"/>
              <RegistryKey
                Root="HKLM"
                Key="Software\Microsoft\Windows\CurrentVersion\Run">
                <RegistryValue Id="MyApp.exe" Name="MyApp" Value="[INSTALLLOCATION]MyApp.exe" Type="string" />
              </RegistryKey>
          </Component>     
 </DirectoryRef>   
</Fragment> 
</Wix>
<!-- Product.wxs -->
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">    
  <?include Variables.wxi?>    
  <Product Id="*"
           Name="$(var.ProductName)"
           Language="1033"
           Version="$(var.Version)"
           Manufacturer="$(var.Manufacturer)"
           UpgradeCode="MY_GUID">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <WixVariable Id="WixUILicenseRtf" Value="eula.rtf" />    
    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <MajorUpgrade
       AllowDowngrades="no" 
       DowngradeErrorMessage="New version is already installed."
       AllowSameVersionUpgrades="no"
       Schedule="afterInstallInitialize"/>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLLOCATION" Name="MyApp" />
      </Directory>
    </Directory>

    <Feature Id="ProductFeature" Title="MyApp" Level="1">
      <ComponentRef Id="ProductComponents" />
    </Feature>

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION"></Property>
    <UIRef Id="WixUI_InstallDir"/>

    <CustomAction Id="LaunchApp" Directory="INSTALLLOCATION" ExeCommand="[SystemFolder]cmd.exe /C start MyApp.exe" />
    <InstallExecuteSequence>
      <Custom Action="LaunchApp" After="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
    </InstallExecuteSequence>
  </Product>
</Wix>

我想实现自动启动myApp。

1 个答案:

答案 0 :(得分:1)

最可能的问题是它需要提升,因此会被UAC阻止: https://blogs.msdn.microsoft.com/uac/2006/08/23/elevations-are-now-blocked-in-the-users-logon-path/ 和: Program needing elevation in Startup registry key (windows 7)

如果不是这样,那么检查注册表运行键中的路径是否实际正确(在32位或64位注册表中)。

“Windows启动时”运行键中的条目不会运行。它们在用户登录时启动。如果您确实希望在Windows启动时运行某些内容,则需要在Windows启动时启动的服务或任务计划程序条目。

相关问题