public void Execute(ExecutingOptions options) { var installer = new ProjectInstaller { DisplayName = options.Name, Description = options.Name, Context = new InstallContext() }; installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location); installer.Install(new Hashtable()); using (var system = Registry.LocalMachine.OpenSubKey("System")) using (var currentControlSet = system.OpenSubKey("CurrentControlSet")) using (var services = currentControlSet.OpenSubKey("Services")) using (var service = services.OpenSubKey(installer.ServiceName, true)) { var path = (string)service.GetValue("ImagePath"); options.Action = Action.Server; service.SetValue("ImagePath", path + options); } }
public void Execute(ExecutingOptions options) { var installer = new ProjectInstaller { DisplayName = options.Name, Description = options.Name, Context = new InstallContext() }; if (!string.IsNullOrEmpty(options.Account)) { if (string.IsNullOrEmpty(options.Password)) { throw new InvalidOperationException("When /Action is Install and /Account is set /Password is required."); } installer.SetUserAccount(options.Account, options.Password); } installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location); installer.Install(new Hashtable()); using (var system = Registry.LocalMachine.OpenSubKey("System")) using (var currentControlSet = system.OpenSubKey("CurrentControlSet")) using (var services = currentControlSet.OpenSubKey("Services")) using (var service = services.OpenSubKey(installer.ServiceName, true)) { var path = (string)service.GetValue("ImagePath"); options.Action = Action.Server; service.SetValue("ImagePath", path + options); } }
static void Main( string[] args ) { InstallContext context = new InstallContext(); context.Parameters["assemblypath"] = typeof( ProjectInstaller ).Assembly.CodeBase.Substring( 8 ).Replace( '/', '\\' ); context.Parameters["Mode"] = "1"; using (ProjectInstaller installer = new ProjectInstaller { AutoTestMode = true, Context = context }) { Dictionary<string, string> items = new Dictionary<string, string>(); installer.Install( items ); } }
static void Main(string[] args) { InstallContext context = new InstallContext(); context.Parameters["assemblypath"] = typeof(ProjectInstaller).Assembly.CodeBase.Substring(8).Replace('/', '\\'); context.Parameters["Mode"] = "1"; using (ProjectInstaller installer = new ProjectInstaller { AutoTestMode = true, Context = context }) { Dictionary <string, string> items = new Dictionary <string, string>(); installer.Install(items); } }