VB.net做的windows service,我需要Interact with desktop。 普通安装后我可以自行设置,但是装到客户机器上的时候我希望安装的时候就就选择了Interact with desktop.
我在网上找到一段代码
VB.NET code
Imports System.ComponentModel
Imports System.Configuration.Install
Imports Microsoft.Win32
PublicClass ProjectInstaller
PublicSubNew()
MyBase.New()
'Add initialization code after the call to InitializeComponent'This call is required by the Component Designer. InitializeComponent()
'Add initialization code after the call to InitializeComponentDim si AsNew ServiceProcess.ServiceInstaller
si.ServiceName ="StorePlanService"
si.DisplayName ="StorePlanService"
si.StartType = ServiceProcess.ServiceStartMode.Manual
Me.Installers.Add(si)
Dim spi AsNew ServiceProcess.ServiceProcessInstaller()
spi.Account = System.ServiceProcess.ServiceAccount.LocalSystem
spi.Password =Nothing
spi.Username =NothingMe.Installers.Add(spi)
Dim ckey As RegistryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\StorePlanService", True)
If ckey.GetValue("Type") <>NothingThen
ckey.SetValue("Type", (ckey.GetValue("Type") Or256))
EndIfEnd SubProtectedOverridesSub Finalize()
MyBase.Finalize()
End Sub