c# 服务安装后自动启动
switch (rs)
{
case 1:
var path = @"e:\WindowsServiceTest.exe" + " s";
Process.Start("sc", "create myserver binpath= \"" + path + "\" displayName= StrongunionService start= auto");
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
string Cmdstring = "sc start myserver"; //CMD命令
p.StandardInput.WriteLine(Cmdstring);
Console.WriteLine("安装成功");
Console.Read();
break;
case 2:
Process p2 = new Process();
p2.StartInfo.FileName = "cmd.exe";
p2.StartInfo.UseShellExecute = false;
p2.StartInfo.RedirectStandardInput = true;
p2.StartInfo.RedirectStandardOutput = true;
p2.StartInfo.RedirectStandardError = true;
p2.StartInfo.CreateNoWindow = true;
p2.Start();
string Cmdstring2 = "sc stop myserver"; //CMD命令
p2.StandardInput.WriteLine(Cmdstring2);
Process.Start("sc", "delete myserver");
Console.WriteLine("卸载成功");
Console.Read();
break;
case 3:
Console.WriteLine("卸载成功000");
Console.Read();
break;
}
c# 服务安装后自动启动的更多相关文章
- C#编写的windows服务安装后启动提示“服务启动后又停止了”
使用C#编写的windows服务安装到服务器上行后进行启动时,总是提示“服务启动后又停止了”. 检查了服务逻辑是没问题,安装在开发本地也是正常,网上查了资料说是可能是服务没有注册,我检查了服务是正常注 ...
- C# — Windows服务安装后自动停止问题
今天在使用VS创建一个Windows服务时,为了得到一些提示,引用了Windows.Forms程序集,然后使用MessageBox.Show()方法渴望得到一些弹窗提示: 但是最后在安装好服务后,在任 ...
- Windows 服务 安装后自启动
[RunInstaller(true)] public partial class ProjectInstaller : System.Configuration.Install.Installer ...
- Windows服务安装完成后自动启动
public ServiceInstaller() { //... Installer code here this.AfterInstall += new InstallEventHandler(S ...
- .Net实现Windows服务安装完成后自动启动的两种方法
考虑到部署方便,我们一般都会将C#写的Windows服务制作成安装包.在服务安装完成以后,第一次还需要手动启动服务,这样非常不方便. 方法一:在安装完成事件里面调用命令行的方式启动服务 此操作之前要先 ...
- Zookeeper Windows版的服务安装和管理工具
以前研究过负载均衡,最近正在项目上实施(从来没做过小项目以上级别的东西,哈).然后遇到了多个一模一样但是同时运行的服务.不同服务但依赖同相同的配置数据(前端网页服务:Nginx+IIS+nodejs. ...
- [转].Net Windows服务安装完成后自动启动
本文转自:http://www.cnblogs.com/hb_cattle/archive/2011/12/04/2275319.html 考虑到部署方便,我们一般都会将C#写的Windows服务制作 ...
- 如何配置Linux的服务设置为自动启动或崩溃重新启动后
介绍 在本教程中,自动启动 Linux 服务,我们将退后一步,更详细地解释 init 进程. 你应该很好地了解它们如何控制守护进程的启动行为. 在第一部分本系列教程我们分享使用 MySQL 的如何崩溃 ...
- MySQL 安装和启动服务,“本地计算机 上的 MySQL 服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。”
MySQL 安装和启动服务,以及遇到的问题 MySQL版本: mysql-5.7.13-winx64.zip (免安装,解压放到程序文件夹即可,比如 C:\Program Files\mysql-5. ...
随机推荐
- jdk 环境
一.下载 jdk 下载版本为:Linux x64 最新版本 curl -L -O http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u ...
- QDoubleSpinBox浮点型数字调节框
样式: import sys from PyQt5.QtWidgets import QApplication, QWidget, QDoubleSpinBox class Demo(QWidget) ...
- Python之print(args)与sys.stdout.write(string)使用总结
一.sys.stdout.write(string) import sys; # sys.stdout.write(): # 1.默认不换行 # 2.参数必须是字符串 # demo 01 x = &q ...
- python时间序列画图plot总结
画图从直觉上来讲就是为了更加清晰的展示时序数据所呈现的规律(包括趋势,随时间变化的规律(一周.一个月.一年等等)和周期性规律),对于进一步选择时序分析模型至关重要.下面主要是基于pandas库总结一下 ...
- Nginx实战之让用户通过用户名密码认证访问web站点
1.Nginx实战之让用户通过用户名密码认证访问web站点 [root@master ~]# vim /usr/local/nginx/conf/extra/www.conf server { lis ...
- Dubbo多版本
当服务提供者提供的服务接口出现不兼容升级时,可以设置版本号,使用多个版本号(version)进行过渡. 1).服务提供者配置文件 <dubbo:service ref="userSer ...
- 【转】Linux中常见问题(磁盘 定时任务)
[转]Linux中常见问题(磁盘 定时任务) 第1章 linux无法上网 1) 第一步,先ping域名. ping www.baidu.com 2)再ping一个公网ip , ping 223 ...
- Python|绝不乱入的靠谱书单
- RNN(2) ------ “《A Critical Review of Recurrent Neural Networks for Sequence Learning》RNN综述性论文讲解”(转载)
原文链接:http://blog.csdn.net/xizero00/article/details/51225065 一.论文所解决的问题 现有的关于RNN这一类网络的综述太少了,并且论文之间的符号 ...
- mysql授权报错 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
授权用户时报错,ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 原因为其实与val ...