在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
先看下代码 1 namespace UpdaterServer 2 { 3 class Program 4 { 5 static void Main(string[] args) 6 { 7 if (args == null || args.Length == 0) 8 { 9 ServiceBase[] servicesToRun; 10 servicesToRun = new ServiceBase[] 11 { 12 new UpdateClientServer() 13 }; 14 ServiceBase.Run(servicesToRun); 15 } 16 else if (args.Length == 1) 17 { 18 switch (args[0]) 19 { 20 //安装并启动服务 21 case "1": 22 //取当前可执行文件路径 23 var path = Process.GetCurrentProcess().MainModule.FileName + ""; 24 Process.Start("sc", "create UpdateClientServer binpath= \"" + path + "\" displayName= UpdateClientServer "); 25 Process.Start("sc", "start UpdateClientServer"); 26 break; 27 case "2": 28 Process.Start("sc", "stop UpdateClientServer"); 29 Process.Start("sc", "delete UpdateClientServer"); 30 break; 31 default: 32 Console.WriteLine("[1]安装并启动服务 [2]停止并卸载服务 [其他不识别字符]帮助信息 "); 33 break; 34 } 35 } 36 } 37 } 38 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论