2010-06-10 63 views
4

我有WPF應用程序。我想通過複選框給用戶賦予App(exe文件)到Windows啓動的能力。我如何在C#中執行此程序?如何把exe文件在Windows啓動

+0

有同樣的問題.. :-) stackoverflow的岩石。 :-) – 2011-05-27 11:17:18

回答

6

您需要將應用程序添加到註冊表中的HKCU\Software\Microsoft\Windows\CurrentVersion\Run關鍵。請參閱C#中的示例:Managing Start-up

1

您可以將您的程序添加到註冊表中,該文件夾將是[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]。你可以通過添加一個新的字符串值來實現,例如。 "Notepad"="c:\windows\notepad.exe"

A short guide

1

我將它僅作爲參考添加,因爲問題已得到解答。

這些都是在啓動時註冊應用程序的所有可能位置。

SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServicesOnce 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServices 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\Setup 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunEx 
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run