1

I'm trying to register app to autorun when Windows is launches. I can't understand why it doesn't work?

I'm trying to do that:

<!-- 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>

I want to achieve auto start myApp.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Buzzy
  • 1,783
  • 18
  • 15
  • Your custom action will start the application after installation is finished. But your question says that you want the app to autorun when windows launches. What is it that you want? – Harsh Pandey Jul 17 '16 at 18:48
  • My custom action run the app after installation is finished - it is work correct. I want to register my app to auto run each time when windows is launched. It is in RegistryKey tag. – Buzzy Jul 17 '16 at 23:13
  • Oh my bad, I totally missed that part at the top. That looks correct tbh. [This](http://stackoverflow.com/a/1052940/6570665) might help you still. – Harsh Pandey Jul 18 '16 at 02:46
  • Harsh, thx. Actually I saw that and other solutions. All of them looks like mine. The problem is somewhere in my implementation but I can not figure out where. – Buzzy Jul 18 '16 at 04:00

1 Answers1

1

The most likely issue is that it needs elevation and therefore will be blocked by UAC: https://blogs.msdn.microsoft.com/uac/2006/08/23/elevations-are-now-blocked-in-the-users-logon-path/ and: Program needing elevation in Startup registry key (windows 7)

If it's not that, then check that the path in the registry Run key is actually correct (in the 32-bit or 64-bit registry).

Entries in the Run key do not run "when Windows is launched". They start when the user logs on. If you really want something to run when Windows starts you need a service or a Task Scheduler entry that starts when Windows starts.

Community
  • 1
  • 1
PhilDW
  • 20,260
  • 1
  • 18
  • 28