Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using (var inst = new AssemblyInstaller(typeof(MyNamespace.Program).Assembly, new string[] { })) {
  2. IDictionary state = new Hashtable();
  3. inst.UseNewContext = true;
  4. try {
  5. if (uninstall) {
  6. inst.Uninstall(state);
  7. } else {
  8. inst.Install(state);
  9. inst.Commit(state);
  10. }
  11. } catch {
  12. try {
  13. inst.Rollback(state);
  14. } catch { }
  15. throw;
  16. }
  17. }
  18.  
  19. using (var sc = new ServiceController("the service's name"))
  20. {
  21. sc.Start();
  22. sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(20));
  23. }
  24.  
  25. ServiceInstaller
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement