home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 September / CHIPCD_9_99.iso / software / uaktualnienia / OptionPackPL / iis4_07.cab / dfoot.vbs < prev    next >
Text File  |  1998-04-27  |  4KB  |  156 lines

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. '  Document Footer Utility   
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6. '  Description:
  7. '  ------------
  8. '  This sample admin script allows you to configure document footers.
  9. '
  10. '  To Run:  
  11. '  -------
  12. '  This is the format for this script:
  13. '  
  14. '      cscript metaback.vbs 
  15. '  
  16. '  NOTE:  If you want to execute this script directly from Windows, use 
  17. '  'wscript' instead of 'cscript'. 
  18. '
  19. '''''''''''''''''''''''''''''''''''''''''''''
  20.  
  21. ' Initialize error checking
  22. On Error Resume Next
  23.  
  24. ' Initialize variables
  25. Dim ArgCount, InputError, FootEnabled, FootDoc, FootPath, ThisObj, EnableModify, ClearFlag
  26.  
  27. ' Default values
  28. ArgCount = 0
  29. FootPath = ""  ' This MUST be set by user via command-line
  30. FootDoc = ""
  31. FootEnabled = False
  32. EnableModify = False
  33. ClearFlag = False
  34.  
  35.  
  36.   ' ** Parse Command Line
  37.  
  38.     ' Loop through arguments
  39.     While ArgCount < Wscript.Arguments.Count
  40.       
  41.        
  42.       ' Determine switches used
  43.       Select Case Wscript.Arguments(ArgCount)
  44.  
  45.          Case "-s":   ' Sets default footer explicitly to string
  46.             ' Move to next arg, which should be parameter
  47.             ArgCount =  ArgCount + 1  
  48.             If ArgCount => Wscript.Arguments.Count Then
  49.                Call UsageMsg
  50.             Else
  51.                FootDoc = "STRING:" & Wscript.Arguments(ArgCount)
  52.             End If
  53.  
  54.          Case "-f":   ' Sets default footer to a file
  55.             ' Move to next arg, which should be parameter
  56.             ArgCount =  ArgCount + 1  
  57.             If ArgCount => Wscript.Arguments.Count Then
  58.                Call UsageMsg
  59.             Else
  60.                FootDoc = "FILE:" & Wscript.Arguments(ArgCount)
  61.             End If
  62.  
  63.          Case "+d":  ' Enables doc footers
  64.             FootEnabled = True
  65.             EnableModify = True
  66.  
  67.          Case "-d":  ' Disables doc footers
  68.             FootEnabled = False
  69.             EnableModify = True
  70.  
  71.          Case "-c":  ' Clears all document footer settings from node
  72.             ClearFlag = True
  73.  
  74.          Case "-h":  ' Help!
  75.             UsageMsg;
  76.  
  77.          Case Else:  ' ADsPath, we hope 
  78.             If FootPath <> "" Then  ' Only one name allowed
  79.                Call UsageMsg
  80.             Else
  81.                FootPath = Wscript.Arguments(ArgCount)
  82.             End If
  83.  
  84.       End Select
  85.  
  86.       ' Move pointer to next argument
  87.       ArgCount = ArgCount + 1
  88.  
  89.     Wend
  90.  
  91.   ' Quick screen to make sure input is valid
  92.   If FootPath = "" Then
  93.     Call UsageMsg
  94.   End If
  95.  
  96.     
  97.   ' **Perform Backup:
  98.   ' First, create instance of ADSI object
  99.   Set ADSIObj = GetObject(FootPath)
  100.  
  101.   ' Error getting that object?
  102.   If Err.Number <> 0 Then
  103.     Wscript.Echo "Error getting object at path " & FootPath & "."
  104.     Wscript.Quit
  105.   End If
  106.  
  107.  
  108.   ' If no changes, then simply display current settings
  109.   If (EnableModify = False) And (FootDoc = "") And (ClearFlag = False)  Then   ' Display current status
  110.     If ADSIObj.EnableDocFooter = True Then
  111.        Wscript.Echo FootPath & ": Footers currently enabled, value = " & ADSIObj.DefaultDocFooter
  112.     Else
  113.        Wscript.Echo FootPath & ": Footers currently disabled, value = " & ADSIObj.DefaultDocFooter
  114.     End If
  115.     Wscript.Quit
  116.   End If
  117.  
  118.  ' Change settings for node
  119.   If ClearFlag = True Then 
  120.      ADSIObj.EnableDocFooter = False
  121.      ADSIObj.DefaultDocFooter = ""
  122.   Else
  123.      If EnableModify Then ADSIObj.EnableDocFooter = FootEnabled
  124.      If FootDoc <> "" Then ADSIObj.DefaultDocFooter = FootDoc 
  125.   End If
  126.  
  127.   ' Save new settings back to node
  128.   ADSIObj.SetInfo
  129.  
  130.   ' Error saving info to object?
  131.   If Err.Number <> 0 Then
  132.     Wscript.Echo "Error setting document footer info for path " & FootPath & "."
  133.     Wscript.Quit
  134.   End If
  135.  
  136.   ' Display results
  137.   If ADSIObj.EnableDocFooter = True Then 
  138.     Wscript.Echo FootPath & ": Document footers enabled, value = " & ADSIObj.DefaultDocFooter
  139.   Else
  140.     Wscript.Echo FootPath & ": Document footers disabled, value = " & ADSIObj.DefaultDocFooter
  141.   End If
  142.  
  143.  
  144.  
  145. ' Displays usage message, then QUITS
  146. Sub UsageMsg
  147.     Wscript.Echo "Usage:  cscript dfoot.vbs <ADsPath> [+d|-d footers enabled] [[-s <string>] | [-f <filename>]]"
  148.     Wscript.Quit
  149. End Sub
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.