Skip to content

Instantly share code, notes, and snippets.

@t3knoid
Created April 29, 2019 20:19
Show Gist options
  • Save t3knoid/74eaec75e8e2b40d6e30e829591cde3b to your computer and use it in GitHub Desktop.
Save t3knoid/74eaec75e8e2b40d6e30e829591cde3b to your computer and use it in GitHub Desktop.
Modify Windows service registry key so that we can pass parameters.
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