人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

May 15, 2006

操作Windows Service

Filed under: Code snippets

Namespace: System.ServiceProcess
Assembly: system.serviceprocess.dll

//—-判断本机是否运行了某项服务

ServiceController service = new ServiceController("MSSQLSERVER");

if(service.Stauts == ServiceProcess.ServiceControllerStatus.Running){…}

//—改变Service运行状态

private const string myService = "XXX";

ServiceController service = new ServiceController(myService );

if(service.Status != ServiceControllerStatus.Stopped)

{

    service.Stop();

    serviceControl.WaitForStatus(ServiceControllerStatus.Stopped);

}

service.Start();

//—-安装.net service

%SystemRoot%\Microsoft.NET\Framework\<Version>\InstallUtil /u /name=S1 myService.exe
%SystemRoot%\Microsoft.NET\Framework\<Version>\InstallUtil /name=S1 myService.exe
%SystemRoot%\system32\services.msc /s

//—-命令行操作

net start "myService"

net stop "myService"

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/05/15/p30/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham