我想註冊我的應用程序,以在啓動窗口時根據退出對話框中的複選框啓動。WiX:有條件地註冊應用程序以在Windows啓動時啓動
我跟着this,但似乎甚至出現結束對話框(和相關的複選框)之前寫入註冊表。
我的代碼是: 在product.wxs:
<Property Id="APP_AUTOMATIC_START_UP">1</Property>
....
<Component Id="AppAutoStartUp" Guid="{MyGuid}">
<RegistryValue Id="App.rst" Root="HKCU" Action="write" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="App" Value="[#MyApp.exe]" Type="string" />
<Condition><![CDATA[Installed OR APP_AUTOMATIC_START_UP]]></Condition>
在MyExitDialog.wxs:
<Control Id="AutomaticStartup" Type="CheckBox" Height="18" Width="295" X="135" Y="190" Text="Run App upon windows startUp" Property="APP_AUTOMATIC_START_UP" CheckBoxValue="1">
<Condition Action="hide" >Installed</Condition>
<Condition Action="show" >NOT Installed</Condition>
編輯: 我嘗試添加的關鍵註冊表和情況用戶取消選中複選框使用自定義操作將其刪除。我的代碼:
[CustomAction]
public static ActionResult NotRunOnStartUp(Session session)
{
session.Log("Begin NotRunOnStartUp");
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.DeleteValue("MyApp");
return ActionResult.Success;
}
<Binary Id="NotRunOnStartUpBinary" src="..\CustomActions\NotRunOnStartUp\bin\$(var.Configuration)\NotRunOnStartUp.CA.dll" />
...
<CustomAction Id="NotRunOnStartUpCA"
Return="check"
Execute="immediate"
BinaryKey="NotRunOnStartUpBinary"
DllEntry="NotRunOnStartUp" />
...
<Publish Dialog="MyExitDialog" Control="Finish" Event="DoAction" Value="NotRunOnStartUpCA">APP_AUTOMATIC_START_UP= 0 and NOT Installed</Publish>
結果是,安裝目錄中我寫的關鍵註冊表,但是當我取消選中複選框,然後按完成,在沒有從註冊表中刪除的關鍵。 任何想法爲什麼?
謝謝!它已經可以從應用程序配置,但我仍然希望從安裝程序。我根據您的回答編輯了我的問題,嘗試使用自定義操作無效。 – eskadi