home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / regfilt.vbs < prev    next >
Text File  |  1997-10-25  |  3KB  |  119 lines

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. '  Filter Registration Utility  
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6.  
  7. '  Description:
  8. '  ------------
  9. '  This sample admin script allows you to install a new ISAPI filter on the server or
  10. '  the service.
  11. '
  12. '  To Run:  
  13. '  -------
  14. '  This is the format for this script:
  15. '  
  16. '      cscript regfilt.vbs <filterpath> [-n <filtername>]
  17. '  
  18. '  NOTE:  If you want to execute this script directly from Windows, use 
  19. '  'wscript' instead of 'cscript'. 
  20. '
  21. '''''''''''''''''''''''''''''''''''''''''''''
  22.  
  23. Option Explicit
  24.  
  25. ' Initialize error checking
  26. On Error Resume Next
  27.  
  28. ' Initialize variables
  29. Dim ArgCount, FName, FPath, FiltersObj, FilterObj, FullPath, LoadOrder
  30.  
  31. ' Default values
  32. ArgCount = 0
  33. FName = ""  ' Name of filter
  34. FPath = ""      ' Path to filter DLL
  35.  
  36.  
  37.  
  38.   ' ** Parse Command Line
  39.  
  40.     ' Loop through arguments
  41.     While ArgCount < Wscript.Arguments.Count
  42.       
  43.       ' Determine switches used
  44.       Select Case Wscript.Arguments(ArgCount)
  45.  
  46.          Case "-n":   ' Name of filter
  47.             ' Move to next arg, which should be parameter
  48.             ArgCount =  ArgCount + 1  
  49.             If ArgCount => Wscript.Arguments.Count Then
  50.                Call UsageMsg
  51.             Else
  52.                FName = Wscript.Arguments(ArgCount)
  53.             End If
  54.  
  55.          Case "-h", "-?", "/?":    ' Help!
  56.             Call UsageMsg
  57.  
  58.          Case Else:
  59.             If FPath <> "" Then  ' Only one name allowed
  60.                Call UsageMsg
  61.             Else
  62.                FPath = Wscript.Arguments(ArgCount)
  63.             End If
  64.  
  65.       End Select
  66.  
  67.       ' Move pointer to next argument
  68.       ArgCount = ArgCount + 1
  69.  
  70.     Wend
  71.  
  72.     ' Path to DLL filter must be provided 
  73.     If FPath = "" Then UsageMsg   
  74.     
  75.     ' Set filter name to path, if none provided
  76.     If FName = "" Then FName = FPath
  77.  
  78.  
  79.     ' Access ADSI object for the IIsFilters object
  80.     ' NOTE:  If you wish to add a filter at the server level, you will have to check
  81.     ' the IIsServer object for an IIsFilters node.  If such a node does not exist, it will
  82.     ' need to be created using Create().  
  83.     Set FiltersObj = GetObject("IIS://Localhost/W3SVC/Filters")
  84.  
  85.     ' Create and configure new IIsFilter object
  86.     Set FilterObj = FiltersObj.Create("IIsFilter", FName)
  87.     FilterObj.FilterPath = FPath
  88.  
  89.     ' Write info back to Metabase
  90.     FilterObj.SetInfo
  91.  
  92.  
  93.     ' Modify FilterLoadOrder, to include to new filter
  94.     LoadOrder = FiltersObj.FilterLoadOrder
  95.  
  96.     If LoadOrder <> "" Then LoadOrder = LoadOrder & ","
  97.  
  98.     ' Add new filter to end of load order list
  99.     LoadOrder = LoadOrder & FName
  100.     FiltersObj.FilterLoadOrder = LoadOrder
  101.  
  102.     ' Write changes back to Metabase
  103.     FiltersObj.SetInfo
  104.  
  105.     Wscript.Echo "Filter '" & FName & "' (path " & FPath & ") has been successfully registered."
  106.     Wscript.Quit(0)
  107.  
  108.  
  109. ' Displays usage message, then QUITS
  110. Sub UsageMsg
  111.    Wscript.Echo "Usage:  cscript regfilt.vbs <filterpath> [-n <filtername>] "
  112.    Wscript.Quit
  113. End Sub
  114.  
  115.  
  116.  
  117.  
  118.  
  119.