Created
April 29, 2019 20:19
-
-
Save t3knoid/74eaec75e8e2b40d6e30e829591cde3b to your computer and use it in GitHub Desktop.
Modify Windows service registry key so that we can pass parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void serviceInstaller1_AfterInstall(object sender, System.Configuration.Install.InstallEventArgs e) | |
{ | |
try | |
{ | |
RegistryKey servicesKey = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\"); | |
RegistryKey serviceKey = servicesKey.OpenSubKey(serviceInstaller1.ServiceName, true); | |
serviceKey.SetValue("ImagePath", (string)serviceKey.GetValue("ImagePath") + " dispatcher= " + Context.Parameters["dispatcher"]); | |
} | |
catch (System.Exception ex) | |
{ | |
System.Console.WriteLine("Failed to update service"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment