Results 1 to 5 of 5

Thread: Does anyone know how to ...

  1. #1

    Thread Starter
    Addicted Member AngelinaM's Avatar
    Join Date
    Jan 2001
    Location
    Tampa, Florida
    Posts
    175

    Does anyone know how to ...

    Unload Web services with vb code?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I'm not sure what you mean by "Unload Web services"....

  3. #3
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488
    You mean actually starting and stopping a web service? Could this be done through the command prompt? If so, use the Shell command in VB and issue your commands there.

    -mcd
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

  4. #4
    Addicted Member goudabuddha's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere cheesy
    Posts
    203


    What do you mean?

  5. #5
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Something like this?

    Code:
    '------------------------------------------------------------------------------------------------
    '
    ' Usage: stopweb <--ADSPath|-a server1[,server2,server3...]> 
    ' [--computer|-c COMPUTER1[,COMPUTER2...]]
    ' [--verbose|-v]
    ' [--help|-?]
    '
    ' SERVERx Web Server # to be stopped
    '
    ' Example 1: stopweb --a 3,1
    '------------------------------------------------------------------------------------------------
    
    ' Force explicit declaration of all variables.
    Option Explicit
    
    On Error Resume Next
    
    Dim oArgs, ArgNum, ArgServerList
    Dim verbose
    Dim ArgComputers
    
    ArgComputers = Array("LocalHost")
    verbose = false
    
    Set oArgs = WScript.Arguments
    ArgNum = 0
    While ArgNum < oArgs.Count
    
    Select Case LCase(oArgs(ArgNum))
    Case "--adspath","-a":
    ArgNum = ArgNum + 1
    ArgServerList=Split(oArgs(ArgNum), ",", -1)
    Case "--computer","-c":
    ArgNum = ArgNum + 1
    ArgComputers = Split(oArgs(ArgNum), ",", -1)
    Case "--verbose", "-v":
    verbose = true
    Case "--help","-?":
    Call DisplayUsage
    Case Else:
    Call DisplayUsage
    End Select 
    
    ArgNum = ArgNum + 1
    Wend
    
    If Not IsArray(ArgServerList) Then
    Call DisplayUsage
    End If
    
    Dim compIndex
    
    for compIndex = 0 to UBound(ArgComputers)
    Call ASTStopWebServers(ArgComputers(compIndex),ArgServerList)
    next
    
    Sub ASTStopWebServers(Computer, ServerList)
    Dim ServerNum, oServer
    
    On Error Resume Next
    ServerNum = 0
    Dim fullPath
    While ServerNum <= UBound(ServerList)
    fullPath = "IIS://"&Computer&"/W3svc/"&ArgServerList(ServerNum)
    Trace "Stopping " & fullPath & "."
    Set oServer = GetObject(fullPath)
    If Err <> 0 Then
    Display "Unable to open " & fullPath & "."
    End If
    oServer.Stop
    If Err <> 0 Then
    Display "Unable to stop web server " & fullPath & "."
    End If
    ServerNum = ServerNum + 1
    Wend 
    End Sub
    
    Sub Display(Msg)
    WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
    End Sub
    
    Sub Trace(Msg)
    if verbose = true then
    WScript.Echo Now & " : " & Msg 
    end if
    End Sub
    
    Sub DisplayUsage
    WScript.Echo "Usage: stopweb <--ADSPath|-a server1[,server2,server3...]>"
    WScript.Echo " [--computer|-c COMPUTER1[,COMPUTER2...]]"
    WScript.Echo " [--verbose|-v]"
    WScript.Echo " [--help|-?]"
    WScript.Echo "Note: server1, server2, etc. is the number of the server"
    WScript.Echo "Example 1: stopweb -a 1,2,5"
    WScript.Echo "Example 2: stopweb -c MACHINE1,MACHINE2,MACHINE3 -a 1,2,5"
    WScript.Quit (1)
    End Sub
    Please rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width