| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | 
							- using System.Collections;
 
- using System.ComponentModel;
 
- using System.Configuration.Install;
 
- using System.IO;
 
- using System.Security.Principal;
 
- using System.ServiceProcess;
 
- namespace PRSServer
 
- {
 
-     [RunInstaller(true)]
 
-     public class PRSInstaller : Installer
 
-     {
 
-         private readonly ServiceProcessInstaller _proc;
 
-         private readonly ServiceInstaller _svc;
 
-         public PRSInstaller()
 
-         {
 
-             _proc = new ServiceProcessInstaller();
 
-             _svc = new ServiceInstaller { StartType = ServiceStartMode.Automatic };
 
-             Installers.Add(_svc);
 
-             Installers.Add(_proc);
 
-         }
 
-         protected override void OnBeforeInstall(IDictionary savedState)
 
-         {
 
-             var username = Context.Parameters["/username"];
 
-             if (string.IsNullOrWhiteSpace(username))
 
-             {
 
-                 _proc.Account = ServiceAccount.LocalSystem;
 
-                 _proc.Username = WindowsIdentity.GetCurrent().Name;
 
-             }
 
-             else
 
-             {
 
-                 _proc.Account = ServiceAccount.User;
 
-                 _proc.Username = username;
 
-                 _proc.Password = Context.Parameters["/password"] ?? "";
 
-             }
 
-             _svc.ServiceName = Context.Parameters["/name"];
 
-             _svc.DisplayName = Context.Parameters["/displayName"];
 
-             _svc.Description = Context.Parameters["/description"];
 
-             // Change to .exe because .NET creates and runs .dll
 
-             Context.Parameters["assemblypath"] =
 
-                 "\"" + Path.ChangeExtension(Context.Parameters["assemblypath"], "exe") + "\" /service=" + _svc.ServiceName;
 
-             base.OnBeforeInstall(savedState);
 
-         }
 
-         protected override void OnBeforeUninstall(IDictionary savedState)
 
-         {
 
-             _svc.ServiceName = Context.Parameters["/name"];
 
-             // Change to .exe because .NET creates and runs .dll
 
-             Context.Parameters["assemblypath"] =
 
-                 "\"" + Path.ChangeExtension(Context.Parameters["assemblypath"], "exe") + "\" /service=" + _svc.ServiceName;
 
-             base.OnBeforeUninstall(savedState);
 
-         }
 
-     }
 
- }
 
 
  |