I have made C# project recently and try to run it at windows startup. I configured WXS file in order to write Registry Run key (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run) Below is full of my WXS file.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="NACViewAgentSetupProject" Language="1033" Version="1.0.0.0" Manufacturer="JSGURU" UpgradeCode="MYGUID">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="NACViewAgentSetupProject" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="NACViewAgentSetupProject" />
</Directory>
<Directory Id="ProgramMenuFolder"></Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ProgramMenuFolder">
<Component Id="ApplicationShortcut" Guid="MYGUID">
<Shortcut Id="ApplicationStartMenuShortcut" Name="NACViewAgent" Description="NACVIEW Agent" Target="[INSTALLFOLDER]NACViewAgent.exe" WorkingDirectory="INSTALLFOLDER">
<!--AUMID-->
<ShortcutProperty Key="System.AppUserModel.ID" Value="NACVIEW.NACViewAgent"/>
<!--COM CLSID, specifying which CLSID to activate when toast clicked-->
<ShortcutProperty Key="System.AppUserModel.ToastActivatorCLSID" Value="{MYGUID}"/>
</Shortcut>
<RemoveFile Id="RemoveApplicationShortcut" Directory="ProgramMenuFolder" Name="NACViewAgent" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\NACVIEW" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Component Id="ApplicationAutostart" Guid="MYGUID">
<RegistryValue Root="HKCU" Action="write" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="NACViewAgent" Value="[INSTALLFOLDER]NACViewAgent.exe" Type="string"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<!-- </Component> -->
<Component Id="NACViewAgent.exe" Guid="MYGUID">
<File Id="NACViewAgent.exe" Name="NACViewAgent.exe" Source="$(var.NACViewAgent.TargetDir)NACViewAgent.exe"/>
</Component>
<Component Id="GalaSoft.MvvmLight.dll" Guid="MYGUID">
<File Id="GalaSoft.MvvmLight.dll" Name="GalaSoft.MvvmLight.dll" Source="$(var.NACViewAgent.TargetDir)GalaSoft.MvvmLight.dll"/>
</Component>
<Component Id="Newtonsoft.Json.dll" Guid="MYGUID">
<File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="$(var.NACViewAgent.TargetDir)Newtonsoft.Json.dll"/>
</Component>
<Component Id="Microsoft.WindowsAPICodePack.dll" Guid="MYGUID">
<File Id="Microsoft.WindowsAPICodePack.dll" Name="Microsoft.WindowsAPICodePack.dll" Source="$(var.NACViewAgent.TargetDir)Microsoft.WindowsAPICodePack.dll"/>
</Component>
<Component Id="CommonServiceLocator.dll" Guid="MYGUID">
<File Id="CommonServiceLocator.dll" Name="CommonServiceLocator.dll" Source="$(var.NACViewAgent.TargetDir)CommonServiceLocator.dll"/>
</Component>
<Component Id="System.Windows.Interactivity.dll" Guid="MYGUID">
<File Id="System.Windows.Interactivity.dll" Name="System.Windows.Interactivity.dll" Source="$(var.NACViewAgent.TargetDir)System.Windows.Interactivity.dll"/>
</Component>
<Component Id="GalaSoft.MvvmLight.Extras.dll" Guid="MYGUID">
<File Id="GalaSoft.MvvmLight.Extras.dll" Name="GalaSoft.MvvmLight.Extras.dll" Source="$(var.NACViewAgent.TargetDir)GalaSoft.MvvmLight.Extras.dll"/>
</Component>
<Component Id="GalaSoft.MvvmLight.Platform.dll" Guid="MYGUID">
<File Id="GalaSoft.MvvmLight.Platform.dll" Name="GalaSoft.MvvmLight.Platform.dll" Source="$(var.NACViewAgent.TargetDir)GalaSoft.MvvmLight.Platform.dll"/>
</Component>
<Component Id="Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" Guid="MYGUID">
<File Id="Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" Name="Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" Source="$(var.NACViewAgent.TargetDir)Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll"/>
</Component>
<Component Id="Microsoft.WindowsAPICodePack.Sensors.dll" Guid="MYGUID">
<File Id="Microsoft.WindowsAPICodePack.Sensors.dll" Name="Microsoft.WindowsAPICodePack.Sensors.dll" Source="$(var.NACViewAgent.TargetDir)Microsoft.WindowsAPICodePack.Sensors.dll"/>
</Component>
<Component Id="Microsoft.WindowsAPICodePack.Shell.dll" Guid="MYGUID">
<File Id="Microsoft.WindowsAPICodePack.Shell.dll" Name="Microsoft.WindowsAPICodePack.Shell.dll" Source="$(var.NACViewAgent.TargetDir)Microsoft.WindowsAPICodePack.Shell.dll"/>
</Component>
<Component Id="Microsoft.WindowsAPICodePack.ShellExtensions.dll" Guid="MYGUID">
<File Id="Microsoft.WindowsAPICodePack.ShellExtensions.dll" Name="Microsoft.WindowsAPICodePack.ShellExtensions.dll" Source="$(var.NACViewAgent.TargetDir)Microsoft.WindowsAPICodePack.ShellExtensions.dll"/>
</Component>
<!--Tell WiX to install the shortcut-->
<ComponentRef Id="ApplicationShortcut"/>
<ComponentRef Id="ApplicationAutostart"/>
</ComponentGroup>
</Fragment>
</Wix>
build wix project and install it, then I can see NACViewAgent value in Run key like below.
I restarted my machine. but unfortunately my exe does not auto start when windows boots.
Thanks in advance!