Inno Setup的为Windows服务? [英] Inno Setup for Windows service?
问题描述
我有一个.net Windows服务。我想创建一个安装程序来安装Windows服务。
I have a .Net Windows service. I want to create an installer to install that windows service.
基本上它有做到以下几点:
Basically it has to do the following:
- 包
installutil.exe
(需要它?) - 运行
installutil.exe
MyService.exe - 开始为MyService
- Pack
installutil.exe
(Is it required?) - Run
installutil.exe
MyService.exe - Start MyService
另外,我想提供它运行以下命令卸载程序:
Also, I want to provide an uninstaller which runs the following command:
installutil.exe /u MyService.exe
如何做到这些使用Inno Setup的?
How to do these using Inno Setup?
推荐答案
您不需要 installutil.exe
,也许你甚至没有权利再分发
You don't need installutil.exe
and probably you don't even have rights to redistribute it.
下面是我在做这在我的应用程序的方式:
Here is the way I'm doing it in my application:
using System;
using System.Collections.Generic;
using System.Configuration.Install;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
static void Main(string[] args)
{
if (System.Environment.UserInteractive)
{
string parameter = string.Concat(args);
switch (parameter)
{
case "--install":
ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
break;
case "--uninstall":
ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
break;
}
}
else
{
ServiceBase.Run(new WindowsService());
}
}
基本上,你可以有你的服务,通过使用<一个自身的安装/卸载href=\"http://msdn.microsoft.com/en-us/library/system.configuration.install.managedinstallerclass.aspx\"><$c$c>ManagedInstallerClass$c$c>如在我的例子。
Basically you can have your service to install/uninstall on its own by using ManagedInstallerClass
as shown in my example.
然后,它只是物质添加到您的InnoSetup脚本是这样的:
Then it's just matter of adding into your InnoSetup script something like this:
[Run]
Filename: "{app}\MYSERVICE.EXE"; Parameters: "--install"
[UninstallRun]
Filename: "{app}\MYSERVICE.EXE"; Parameters: "--uninstall"
这篇关于Inno Setup的为Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!