如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

Description of your first forum.

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子goddy » 星期二, 2004年4月13日 11:50


如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子重庆森林 » 星期四, 2004年4月15日 13:46


其实没必要写程序的,用系统的计划任务定时运行iisreset.exe就行了。iisreset.exe是系统自带的,在system32目录里。
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子lich » 星期四, 2004年4月15日 13:48


net start IIS的服务名
net stop ....
也可以做到
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子花形 » 星期四, 2004年4月15日 13:48


Option Explicit

' define ADSI status constants
Const ADS_SERVICE_STOPPED          = 1
Const ADS_SERVICE_START_PENDING    = 2
Const ADS_SERVICE_STOP_PENDING     = 3
Const ADS_SERVICE_RUNNING          = 4
Const ADS_SERVICE_CONTINUE_PENDING = 5
Const ADS_SERVICE_PAUSE_PENDING    = 6
Const ADS_SERVICE_PAUSED           = 7
Const ADS_SERVICE_ERROR            = 8

' define string constants for service methods
Const START_SERVICE    = "START"
Const STOP_SERVICE     = "STOP"
Const PAUSE_SERVICE    = "PAUSE"
Const CONTINUE_SERVICE = "CONTINUE"

' declare global variables
Dim objWsh
Dim objEnv
Dim StrComp uterName

' get the environment variable with the computer name
Set objWsh = WScript.CreateObject("WScript.Shell")
Set objEnv = objWsh.Environment("PROCESS")
strComputerName = objEnv("COMPUTERNAME")

' call CycleService() to stop all the services
CycleService strComputerName,"MSFTPSVC",STOP_SERVICE,True
CycleService strComputerName,"SMTPSVC" ,STOP_SERVICE,True
CycleService strComputerName,"NNTPSVC" ,STOP_SERVICE,True
CycleService strComputerName,"W3SVC"   ,STOP_SERVICE,True
CycleService strComputerName,"IISADMIN",STOP_SERVICE,True

' call CycleService() to start all the services
CycleService strComputerName,"IISADMIN",START_SERVICE,True
CycleService strComputerName,"W3SVC"   ,START_SERVICE,True
CycleService strComputerName,"NNTPSVC" ,START_SERVICE,True
CycleService strComputerName,"SMTPSVC" ,START_SERVICE,True
CycleService strComputerName,"MSFTPSVC",START_SERVICE,True

' ****************************************
' CycleService() subroutine
' this subroutine is passed four variables:
'   1. strComputer  = the name of the computer
'   2. strService   = the name of the service (e.g. w3svc, smtpsvc, etc.)
'   3. strOperation = the operation to be completed (e.g. start, stop)
'   4. boolTrace    = True will output trace information, False will not
' ****************************************
Sub CycleService(strComputer,strService,strOperation,boolTrace)
 On Error Resume Next

 ' declare variables
 Dim objComputer
 Dim objService
 Dim strTrace
 Dim boolSuccess

 ' get ADSI objects and initial variables
 Set objComputer = GetObject("WinNT://" & strComputer & ",computer")
 Set objService  = objComputer.GetObject("Service",strService)
 strTrace = strOperation & " " & strService & " on " & strComputer
 boolSuccess = False

 ' output trace information if needed
 If boolTrace Then Trace "Attempting to " & strTrace & "..."

 ' determine the operation and carry it out
 Select Case (strOperation)
   Case START_SERVICE      
     If (objService.Status = ADS_SERVICE_STOPPED) Then
       objService.Start
       If Err.Number<>0 Then ErrorHandler strTrace
       While objService.Status <> ADS_SERVICE_RUNNING: Wend
       boolSuccess = True
     End If
   Case STOP_SERVICE
     If (objService.Status = ADS_SERVICE_RUNNING) Or (objService.Status = ADS_SERVICE_PAUSED) Then
       objService.Stop
       If Err.Number<>0 Then ErrorHandler strTrace
       While objService.Status <> ADS_SERVICE_STOPPED: Wend
       boolSuccess = True
     End If
   Case PAUSE_SERVICE
     If (objService.Status = ADS_SERVICE_RUNNING) Then
       objService.Pause
       If Err.Number<>0 Then ErrorHandler strTrace
       While objService.Status <> ADS_SERVICE_PAUSED: Wend
       boolSuccess = True
     End If
   Case CONTINUE_SERVICE
     If (objService.Status = ADS_SERVICE_PAUSED) Then
       objService.Continue
       If Err.Number<>0 Then ErrorHandler strTrace
       While objService.Status <> ADS_SERVICE_RUNNING: Wend
       boolSuccess = True
     End If
 End Select

 ' output trace information if needed
 If boolTrace And boolSuccess Then Trace strTrace & " was successful."

End Sub

' ****************************************
' Trace() subroutine
' outputs Time and trace information
' ****************************************
Sub Trace(strText)
 WScript.Echo Now & " : " & strText
End Sub

' ****************************************
' ErrorHandler() subroutine
' outputs error status and exits
' ****************************************
Sub ErrorHandler(strText)

 Dim strError
 strError = Now & " : The following error occurred trying to " & strText & vbCrLf
 strError = strError & vbCrLf & "0x" & Hex(Err.Number) & " - " & Err.Description
 WScript.Echo strError
 WScript.Quit

End Sub
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子花形 » 星期四, 2004年4月15日 13:57


delphi中控制如下:
  function CycleService(strComputer,strService,strOperation : string) : boolean;
  var
       objComputer, objService : OleVariant;
       I: IADsContainer;
       ADs: IADs;
  begin
      objComputer := ADsGetObject('WinNT://' + StrComp uter + ',computer', IID_IADsContainer, IUnknown(I));
      objService  := I.GetObject('Service',strService);
//       objService  := objComputer.GetObject('Service',strService);
      result := False;

      if strOperation = START_SERVICE then begin
          if (objService.Status = ADS_SERVICE_STOPPED) Then begin
              try
                  objService.Start;
              except
                  on e:Exception do begin
                      messagebox(0, PChar(e.Message), '错误', mb_ok + mb_iconerror);
                      Exit;
                  end;
              end;
              While objService.Status <> ADS_SERVICE_RUNNING do begin
                  Application.ProcessMessages;
              end;
              result := True;
              try
                WebSite := CreateOleObject('IISNamespace');
                WebSite := WebSite.GetObject('IIsWebService', 'localhost/w3svc');
                WebServer := WebSite.GetObject('IIsWebServer', '1');
                WebServer.Start;
              except
              end;
          end;
      end;

      if strOperation = STOP_SERVICE then begin
          if (objService.Status = ADS_SERVICE_RUNNING) or (objService.Status = ADS_SERVICE_PAUSED) then begin
              try
                  objService.Stop;
              except
                  on e:Exception do begin
                      messagebox(0, PChar(e.Message), '错误', mb_ok + mb_iconerror);
                      Exit;
                  end;
              end;
              while objService.Status <> ADS_SERVICE_STOPPED do begin
                  Application.ProcessMessages;
              end;
              Result := True;
          end;
      end;

      if strOperation = PAUSE_SERVICE then begin
          if (objService.Status = ADS_SERVICE_RUNNING) Then begin
              try
                  objService.Pause;
              except
                  on e:Exception do begin
                      messagebox(0, PChar(e.Message), '错误', mb_ok + mb_iconerror);
                      Exit;
                  end;
              end;
              While objService.Status <> ADS_SERVICE_PAUSED do begin
                  Application.ProcessMessages;
              end;
              result := True
          end;
      end;

      if strOperation = CONTINUE_SERVICE then begin
          if (objService.Status = ADS_SERVICE_PAUSED) Then begin
              try
                  objService.Continue;
              except
                  on e:Exception do begin
                      messagebox(0, PChar(e.Message), '错误', mb_ok + mb_iconerror);
                      Exit;
                  end;
              end;
              While objService.Status <> ADS_SERVICE_RUNNING do begin
                  Application.ProcessMessages;
              end;
              result := True
          end;
      end;
  end;
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子Likedfw520 » 星期四, 2004年4月15日 14:15


本人站点:http://www.down110.com
欢迎接出宝贵意见!
 
 
 

如何用程序控件IIS重起,大富翁是如何實習的呢﹐我的IIS server老是挂機﹐我要每天定時重起IIS

帖子tmli » 星期四, 2004年4月15日 21:47


有个软件webadmin1.8
管理IIS,管理进程的。
搜索一下