Question

Just about to try and make an install package for an app for that first time with visual studio. I have a registry value that needs to be changed when the program is installed I need the program to start everytime the computer starts.

Is this a fairly trivial task? Could someone point me towards something to try and achieve this.

So far I just have the app with it's forms etc.

Was it helpful?

Solution

I have same problem, I'm using WIX and follow the answer from this Stackoverflow question. I'm also new on WIX, here's my full WIX working script if you might interest (tested on Windows XP & Windows 8.1):

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<Product Id="*" 
       Name="FooSetup" Language="1033"
       Version="1.0.1.1" 
       Manufacturer="Foo Enterprise" 
       UpgradeCode="9235c293-2f08-4c2b-b7a5-69d01f5fca32">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes" />


    <!-- Step 1: Define the directory structure -->
    <Directory Id="TARGETDIR" Name="SourceDir">

       <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="FooSetup" />
       </Directory>

       <Directory Id="ProgramMenuFolder">
          <Directory Id="ApplicationProgramsFolder" Name="Foo Application"/>
       </Directory>

       <Directory Id="DesktopFolder" Name="Desktop" />

    </Directory>

    <!-- Step 2: Add files to your installer package & add autostart feature -->
    <DirectoryRef Id="INSTALLFOLDER">

       <!-- The main executable file-->
       <Component Id="FooApplication" Guid="3F122E60-3745-4AEB-ADA3-B90DCB87E0BD">
          <File Id="FooMainApp" Source="$(var.Foo.TargetPath)" KeyPath="yes"/>
       </Component>

       <!-- The main lib file-->
       <Component Id="FooLib" Guid="83BEDB02-C9F5-4A06-B3D5-0A4D61D6A99C">
          <File Id="FooFileLib" Source="$(var.Foo.Lib.TargetPath)" KeyPath="yes"/>
       </Component>

       <!-- Register windows autostart registry -->
       <Component Id="RegistryEntries" Guid="45C7AC46-1101-4301-83E1-D24392283A60">
          <RegistryValue Type="string"
                   Name="FooStartup"
                   Value="[#FooMainApp]"
                   Root="HKLM"
                   Key="Software\Microsoft\Windows\CurrentVersion\Run"
                   Action="write"/>
       </Component>
    </DirectoryRef>

    <!-- Step 3: Add the shortcut to your installer package -->

    <!-- Start Menu -->
    <DirectoryRef Id="ApplicationProgramsFolder">
       <Component Id="FooShortcutMenu" Guid="3874D005-4E1C-4C0E-9CEA-8CD8D5442B60">
          <Shortcut Id="FooApplicationStartMenuShortcut"
              Name="Foo Application"
              Description="The Foo is Cool!"
              Target="[#FooMainApp]"
              WorkingDirectory="INSTALLFOLDER"/>
          <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\Microsoft\FooApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
       </Component>
    </DirectoryRef>

    <!-- Desktop Menu -->
    <DirectoryRef Id="DesktopFolder">
       <Component Id="FooDesktopShortcutMenu" Guid="D4D0A2ED-C0DB-4524-AC53-D30F904DB846">
          <Shortcut Id="FooApplicationDesktopShortcut"
              Name="Foo Application"
              Description="The Foo is Cool!"
              Target="[#FooMainApp]"
              WorkingDirectory="INSTALLFOLDER"
              Directory="DesktopFolder"/>
          <RemoveFolder Id="DesktopFolder" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\Microsoft\FooApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
       </Component>
    </DirectoryRef>

    <!-- Tell Wix -->
    <Feature Id="ProductFeature" Title="FooSetup" Level="1">
       <ComponentRef Id="FooApplication" />
       <ComponentRef Id="FooLib" />
       <ComponentRef Id="FooShortcutMenu"/>
       <ComponentRef Id="FooDesktopShortcutMenu"/>
       <ComponentRef Id="RegistryEntries" />
    </Feature>
</Product>
</Wix>

OTHER TIPS

It depends the tool you used to create the install package, generally you need to add a String Value under

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run or HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

like "AppName" : "AppPath" You also can achieve this by add the regstry in your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top