Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
3.8 KiB

  1. REM
  2. REM LOCALIZATION
  3. REM
  4. L_SWITCH_MESSAGEID = "-m"
  5. L_SWITCH_SERVER = "-s"
  6. L_SWITCH_INSTANCE_ID = "-i"
  7. L_DESC_PROGRAM = "rcancel - Cancel message in NNTP virtual servers"
  8. L_DESC_MESSAGEID = """<message-id>"" Specify message to cancel"
  9. L_DESC_SERVER = "<server> Specify computer to configure"
  10. L_DESC_INSTANCE_ID = "<virtual server id> Specufy virtual server id"
  11. L_DESC_EXAMPLES = "Examples:"
  12. L_DESC_EXAMPLE1 = "rcancel.vbs -m ""<[email protected]>"""
  13. L_ERR_INVALID_INSTANCE_ID = "Invalid instance identifier."
  14. L_ERR_INVALID_MESSAGEID = "Invalid message identifier."
  15. L_ERR_CANCEL_ERROR = "Error canceling message: "
  16. L_ERR_CANCEL_SUCCESS = "Message canceled."
  17. REM
  18. REM END LOCALIZATION
  19. REM
  20. REM
  21. REM --- Globals ---
  22. REM
  23. dim g_dictParms
  24. dim g_admin
  25. set g_dictParms = CreateObject ( "Scripting.Dictionary" )
  26. REM
  27. REM --- Set argument defaults ---
  28. REM
  29. g_dictParms(L_SWITCH_MESSAGEID) = ""
  30. g_dictParms(L_SWITCH_SERVER) = ""
  31. g_dictParms(L_SWITCH_INSTANCE_ID) = "1"
  32. REM
  33. REM --- Begin Main Program ---
  34. REM
  35. if NOT ParseCommandLine ( g_dictParms, WScript.Arguments ) then
  36. usage
  37. WScript.Quit ( 0 )
  38. end if
  39. set g_admin = CreateObject("NntpAdm.Groups")
  40. server = g_dictParms(L_SWITCH_SERVER)
  41. instance = g_dictParms(L_SWITCH_INSTANCE_ID)
  42. messageid = g_dictParms(L_SWITCH_MESSAGEID)
  43. REM
  44. REM Check arguments
  45. REM
  46. if ( messageid = "" ) then
  47. usage
  48. WScript.Quit 0
  49. end if
  50. if NOT IsNumeric (instance) then
  51. WScript.Echo L_ERR_INVALID_INSTANCE_ID
  52. WScript.Quit 0
  53. end if
  54. if ( Left(messageid,1) <> "<" OR Right(messageid,1) <> ">" ) then
  55. WScript.echo L_ERR_INVALID_MESSAGEID
  56. WScript.Quit 0
  57. end if
  58. REM
  59. REM Cancel message
  60. REM
  61. g_admin.Server = server
  62. g_admin.ServiceInstance = instance
  63. g_admin.CancelMessage( messageid )
  64. REM
  65. REM Show Result
  66. REM
  67. if (err.number <> 0) then
  68. WScript.echo L_ERR_CANCEL_ERROR
  69. WScript.echo Err.Description & " (Error 0x" & Hex(Err.Number) & ")"
  70. else
  71. WScript.echo L_ERR_CANCEL_SUCCESS
  72. end if
  73. WScript.Quit 0
  74. REM
  75. REM
  76. REM --- End Main Program ---
  77. REM
  78. REM
  79. REM
  80. REM ParseCommandLine ( dictParameters, cmdline )
  81. REM Parses the command line parameters into the given dictionary
  82. REM
  83. REM Arguments:
  84. REM dictParameters - A dictionary containing the global parameters
  85. REM cmdline - Collection of command line arguments
  86. REM
  87. REM Returns - Success code
  88. REM
  89. Function ParseCommandLine ( dictParameters, cmdline )
  90. dim fRet
  91. dim cArgs
  92. dim i
  93. dim strSwitch
  94. dim strArgument
  95. fRet = TRUE
  96. cArgs = cmdline.Count
  97. i = 0
  98. do while (i < cArgs)
  99. REM
  100. REM Parse the switch and its argument
  101. REM
  102. if i + 1 >= cArgs then
  103. REM
  104. REM Not enough command line arguments - Fail
  105. REM
  106. fRet = FALSE
  107. exit do
  108. end if
  109. strSwitch = cmdline(i)
  110. i = i + 1
  111. strArgument = cmdline(i)
  112. i = i + 1
  113. REM
  114. REM Add the switch,argument pair to the dictionary
  115. REM
  116. if NOT dictParameters.Exists ( strSwitch ) then
  117. REM
  118. REM Bad switch - Fail
  119. REM
  120. fRet = FALSE
  121. exit do
  122. end if
  123. dictParameters(strSwitch) = strArgument
  124. loop
  125. ParseCommandLine = fRet
  126. end function
  127. REM
  128. REM Usage ()
  129. REM prints out the description of the command line arguments
  130. REM
  131. Sub Usage
  132. WScript.Echo L_DESC_PROGRAM
  133. WScript.Echo vbTab & L_SWITCH_MESSAGEID & " " & L_DESC_MESSAGEID
  134. WScript.Echo vbTab & L_SWITCH_SERVER & " " & L_DESC_SERVER
  135. WScript.Echo vbTab & L_SWITCH_INSTANCE_ID & " " & L_DESC_INSTANCE_ID
  136. WScript.Echo
  137. WScript.Echo L_DESC_EXAMPLES
  138. WScript.Echo L_DESC_EXAMPLE1
  139. WScript.Echo L_DESC_EXAMPLE2
  140. end sub