//运行服务
if (args.Length == 0)
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service()
};
ServiceBase.Run(ServicesToRun);
}
// 安装服务
else if (args[0].ToLower() == "/i" || args[0].ToLower() == "-i")
{
try
{
string[] cmdline = { "/r" };
string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
TransactedInstaller transactedInstaller = new TransactedInstaller();
AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline);
transactedInstaller.Installers.Add(assemblyInstaller);
transactedInstaller.Install(new System.Collections.Hashtable());
}
catch (Exception ex)
{
string msg = ex.Message;
}
}
// 删除服务
else if (args[0].ToLower() == "/u" || args[0].ToLower() == "-u")
{
try
{
string[] cmdline = { };
string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
TransactedInstaller transactedInstaller = new TransactedInstaller();
AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline);
transactedInstaller.Installers.Add(assemblyInstaller);
transactedInstaller.Uninstall(null);
}
catch (Exception ex)
{
string msg = ex.Message;
}
}
分类
- .net (22)
- adf (11)
- android (3)
- article (180)
- astronomy (2)
- block chain (8)
- C# Code (9)
- c/c++ (2)
- cache (8)
- cloud (2)
- consensus (3)
- css (2)
- cve (1)
- db (55)
- digest (1)
- finance (2)
- go (3)
- gps (2)
- hardware (1)
- html (2)
- http (2)
- info (18)
- iot (1)
- it (3)
- java (32)
- javascript (7)
- jsp (2)
- linux (76)
- mail (14)
- math (1)
- message (8)
- mood (4)
- mq (2)
- network (22)
- php (9)
- protocol (4)
- push/pull (2)
- python (5)
- rpc (2)
- search (4)
- servlet (1)
- space (24)
- storage (15)
- technologys (103)
- templete (1)
- virtual machine (7)
- web server (25)
- windows (12)
-
近期文章
其他操作
链接