Microsoft MVP성태의 닷넷 이야기
개발환경 구성 : 24. Smart Start and Stop Service in VS.NET Build [링크 복사], [링크+제목 복사],
조회: 11140
글쓴 사람
정성태 (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)
500정성태11/2/20069593TFS : 50. TfsAlert 0.3.0.0 릴리스
499정성태11/2/200610180개발 환경 구성: 50. VS.NET, .NET Framework QFE 패치
498정성태11/4/20069714TFS : 49. Team Foundation Administrator's Guide 문서 업데이트
497정성태11/1/20069654개발 환경 구성: 49. IE 7 의 "Search Provider" 기능 소개
496정성태11/4/20069184.NET : 26. Download the New Composite UI Application Block Reference Application from IdeaBlade
495정성태11/1/20069270개발 환경 구성: 48. XamlPadX (extended)
494정성태11/1/200610128TFS : 48. SandCastle Team Build targets 파일파일 다운로드1
493정성태10/31/20069414VS.NET IDE : 12. [Orcas] TreeDiff 지원
492정성태10/31/20069937개발 환경 구성: 47. SandCastle 과 NAnt 의 결합
491정성태10/28/200610080SDK : 4. PE/COFF 스펙
490정성태11/4/200613852.NET : 25. C# "const" 키워드와 "static readonly"의 차이
489정성태10/28/200610379Visual C++ : 4. VC++ 8.0 override 키워드 이해 [1]
488정성태10/26/20069800TFS : 47. TFS Application Tier 로부터 Sharepoint 분리해서 설치하는 방법
487정성태10/26/200610059TFS : 46. Project Server 2003 - Team Foundation connector released
486정성태10/25/20069248개발 환경 구성: 46. VS.NET Addin - 디렉터리 단위로 링크 방식으로 파일 추가
485정성태10/23/20069881.NET 3.0 : 5. WinFX (.NET 3.0) Series Presentation Slides
484정성태10/20/20069521개발 환경 구성: 45. Microsoft Best Practices Analyzer 1.0
483정성태10/20/20069309.NET 3.0 : 4. HostNameComparisonMode 의 이해
482정성태10/29/20069684TFS : 45. TeamPlain 1.1 now available
481정성태10/19/20069738TFS : 44. Project Server 2003 and Visual Studio Team System 2005 connector available!
480정성태10/19/20069550개발 환경 구성: 44. IE 7 에 포함된 RSS Platform MiniSDK파일 다운로드1
479정성태10/18/200610142x64 : 2. dynamic_cast is slow in x64
478정성태10/18/20069858개발 환경 구성: 43. IE 7 에서 달라지는 Accept-Language 헤더
477정성태10/18/20069736.NET : 24. ADO.Net 성능 향상 팁
476정성태10/18/200610893TFS : 43. WorkItem 항목 삭제
475정성태11/8/20069998개발 환경 구성: 42. VHD 파일을 가상 하드 디스크로 설정하는 방법파일 다운로드1
... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...