Microsoft MVP성태의 닷넷 이야기
개발환경 구성 : 24. Smart Start and Stop Service in VS.NET Build [링크 복사], [링크+제목 복사],
조회: 11139
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Smart Start and Stop Service in VS.NET Build
; http://blogs.msdn.com/irenak/archive/2006/09/13/752075.aspx

NT 서비스 프로그램에 대한 빌드를 할 때, 빌드 이벤트로 넣어두면 좋겠지요. ^^

If you have a windows service project as part of your solution, you’re quite familiar with the issues it presents -- if the service is running and you’re recompiling either the service project itself, or any assemblies loaded by the service, you’ll get a build error. The script below, courtesy of Scott Jennings, is a way to stop and start service, if it’s installed and is running/stopped correspondingly. All that remains to do it to add the script invocation code to pre-build and post-build event command lines in Visual Studio.

' Usage:

' start /w wscript "\ServiceHelper.vbs"

' Example:

' start /w wscript "C:\Projects\XYZ\ServiceHelper.vbs" start myservice

Dim WMIService

Dim Services

Dim Service

Dim action

Dim result

If Wscript.Arguments.Count <> 2 Then

Wscript.Echo "Usage: ServiceHelper.vbs start|stop ServiceName"

Wscript.Quit 1

End If

Set WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set Services = WMIService.ExecQuery("Select * from Win32_Service where Name = '" + Wscript.Arguments(1) + "'")

If Services.Count > 1 Then

Wscript.Echo "More than one matching service"

Wscript.Quit 1

ElseIf Services.Count = 1 Then

action = Wscript.Arguments(0)

For Each Service In Services

If action = "start" AND Service.State <> "Running" Then

result = Service.StartService()

ElseIf action = "stop" AND Service.State <> "Stopped" Then

result = Service.StopService()

End If

Next

Wscript.Quit(result)

Else

Wscript.Echo "No such service found"

Wscript.Quit 1

End If

Special thanks to Scott Jennings who created this solution!








[최초 등록일: ]
[최종 수정일: 9/14/2006]


비밀번호

댓글 작성자
 




... 16  17  18  19  20  [21]  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
675정성태3/7/20079480Debug : 9. 실행 시 IL 코드 교체 프로파일러
674정성태3/7/200710001.NET 3.5 : 6. Orcas 3월 CTP 에 포함된 LINQ to Entities 예제 문제 수정
673정성태3/7/200710179VS.NET IDE : 22. XML 편집시 XSD 를 이용한 인텔리센스 제공
672정성태3/7/200710301개발 환경 구성: 84. Vista에서 ClickOnce 배포 환경 설정
671정성태3/6/200710317개발 환경 구성: 83. 지문 인식기 관련 프로그래밍
670정성태3/6/20079748개발 환경 구성: 82. Virtual PC 2007의 Vista에 대한 사운드 지원
669정성태3/6/20079799VS.NET IDE : 21. Orcas - 프로젝트 속성창 버그
668정성태3/6/20079715개발 환경 구성: 81. 소프트웨어적으로 Raid 0, 1, 5 구성하는 방법
667정성태3/6/20079621TFS : 86. Orcas에서 변화된 TFS Workspace 관리 방식 3가지
666정성태3/2/20079699VS.NET IDE : 20. Orcas - 스크립트 디버깅 기능 향상
665정성태3/1/200710170.NET 3.5 : 5. 새롭게 추가된 네트워킹 기능
664정성태3/1/20079894VS.NET IDE : 19. Visual Studio Code Metrics
663정성태3/1/200710043VS.NET IDE : 18. Orcas에 포함된 새로운 웹 폼 디자이너
662정성태3/1/200710858Office : 1. Visio 로 UI 프로토타입 설계
661정성태3/1/20079919TFS : 85. Visual Studio Team System Guidance
660정성태2/27/20079482.NET : 54. EntLib 3.0 의 새로운 AppBlock - Policy Injection
659정성태2/25/200710547개발 환경 구성: 80. 새로운 버전의 FxCop 을 빌드 과정에 포함
658정성태2/25/200710409TFS : 84. FxCop 사용자 정의 룰을 위한 단위 테스트 설정
657정성태2/23/200710473Vista : 39. 2초 내에 Resume이 되도록 환경 설정
656정성태2/21/200710610Vista : 38. 개발자를 위한 UAC 관련 문서
655정성태2/21/200710313개발 환경 구성: 79. MSSQL Reporting Service 구성
654정성태2/21/20079711.NET 3.0 : 14. System.IdentityModel.Selectors.CardSpaceSelector 클래스 소개
653정성태2/21/20079786TFS : 83. 팀 빌드 과정에 ClickOnce 빌드 포함
652정성태2/19/200710549개발 환경 구성: 78. FastCGI를 이용하여 Ruby on Rails 를 IIS 에서 구동
651정성태2/18/200710214Vista : 37. x64 - 바이오스 업데이트
650정성태2/17/200710041TFS : 82. ASP.NET - Team Build 후에 파일 복사
... 16  17  18  19  20  [21]  22  23  24  25  26  27  28  29  30  ...