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.

2602 lines
93 KiB

  1. ''''''''''''''''''''''''''''''''''''
  2. '
  3. ' ADSUTIL.VBS
  4. '
  5. ' Date: 7/24/97
  6. ' Revision History:
  7. ' Date Comment
  8. ' 7/24/97 Initial version started
  9. ' 5/8/98 Bug fixes and ENUM_ALL
  10. ' 12/1/98 Fixed display error on list data.
  11. ' 7/27/99 AppCreate2 fix
  12. ' 8/5/99 Dont display encrypted data
  13. ''''''''''''''''''''''''''''''''''''
  14. Option Explicit
  15. On Error Resume Next
  16. ''''''''''''''''''
  17. ' Main Script Code
  18. ''''''''''''''''''
  19. Dim ArgObj ' Object which contains the command line argument
  20. Dim Result ' Result of the command function call
  21. Dim Args(10) ' Array that contains all of the non-global arguments
  22. Dim ArgCount ' Tracks the size of the Args array
  23. ' Used for string formatting
  24. Dim Spacer
  25. Dim SpacerSize
  26. Const IIS_DATA_NO_INHERIT = 0
  27. Const IIS_DATA_INHERIT = 1
  28. Const GENERAL_FAILURE = 2
  29. Const GENERAL_WARNING = 1
  30. Const AppCreate_InProc = 0
  31. Const AppCreate_OutOfProc = 1
  32. Const AppCreate_PooledOutOfProc = 2
  33. Const APPSTATUS_NOTDEFINED = 2
  34. Const APPSTATUS_RUNNING = 1
  35. Const APPSTATUS_STOPPED = 0
  36. Spacer = " " ' Used to format the strings
  37. SpacerSize = Len(Spacer)
  38. ' Note: The default execution mode may be under WScript.exe.
  39. ' That would be very annoying since WScript has popups for Echo.
  40. ' So, I want to detect that, and warn the user that it may cause
  41. ' problems.
  42. DetectExeType
  43. ' Get the Arguments object
  44. Set ArgObj = WScript.Arguments
  45. ' Test to make sure there is at least one command line arg - the command
  46. If ArgObj.Count < 1 Then
  47. DisplayHelpMessage
  48. WScript.Quit (GENERAL_FAILURE)
  49. End If
  50. '*****************************************************
  51. Dim TargetServer 'The server to be examined/modified
  52. Dim I
  53. For I = 0 To ArgObj.Count - 1
  54. If LCase(Left(ArgObj.Item(I), 3)) = "-s:" Then
  55. TargetServer = Right(ArgObj.Item(I), Len(ArgObj.Item(I)) - 3)
  56. Else
  57. Args(ArgCount) = ArgObj.Item(I)
  58. ArgCount = ArgCount + 1
  59. End If
  60. Next
  61. If Len(TargetServer) = 0 Then
  62. TargetServer = "localhost"
  63. End If
  64. '*****************************************************
  65. ' Call the function associated with the given command
  66. Select Case UCase(Args(0))
  67. Case "SET"
  68. Result = SetCommand()
  69. Case "CREATE"
  70. Result = CreateCommand("")
  71. Case "DELETE"
  72. Result = DeleteCommand()
  73. Case "GET"
  74. Result = GetCommand()
  75. Case "ENUM"
  76. ' Result = EnumCommand()
  77. Result = EnumCommand(False, "")
  78. Case "ENUM_ALL"
  79. ' Result = EnumAllCommand()
  80. Result = EnumCommand(True, "")
  81. Case "ENUMALL"
  82. ' Result = EnumAllCommand()
  83. Result = EnumCommand(True, "")
  84. Case "COPY"
  85. Result = CopyMoveCommand(True) ' The TRUE means COPY, not MOVE
  86. Case "MOVE"
  87. Result = CopyMoveCommand(False) ' The FALSE means MOVE, not COPY
  88. Case "CREATE_VDIR"
  89. Result = CreateCommand("IIsWebVirtualDir")
  90. Case "CREATE_VSERV"
  91. Result = CreateCommand("IIsWebServer")
  92. Case "START_SERVER"
  93. Result = StartServerCommand()
  94. Case "STOP_SERVER"
  95. Result = StopServerCommand()
  96. Case "PAUSE_SERVER"
  97. Result = PauseServerCommand()
  98. Case "CONTINUE_SERVER"
  99. Result = ContinueServerCommand()
  100. ' New Stuff being added
  101. Case "FIND"
  102. Result = FindData()
  103. Case "COPY"
  104. WScript.Echo "COPY is not yet supported. It will be soon."
  105. Case "APPCREATEINPROC"
  106. Result = AppCreateCommand(AppCreate_InProc)
  107. Case "APPCREATEOUTPROC"
  108. Result = AppCreateCommand(AppCreate_OutOfProc)
  109. Case "APPCREATEPOOLPROC"
  110. Result = AppCreateCommand(AppCreate_PooledOutOfProc)
  111. Case "APPDELETE"
  112. Result = AppDeleteCommand()
  113. Case "APPUNLOAD"
  114. Result = AppUnloadCommand()
  115. Case "APPDISABLE"
  116. Result = AppDisableCommand()
  117. Case "APPENABLE"
  118. Result = AppEnableCommand()
  119. Case "APPGETSTATUS"
  120. Result = AppGetStatusCommand()
  121. Case "HELP"
  122. DisplayHelpMessageEx
  123. ' End New Stuff
  124. Case Else
  125. WScript.Echo "Command not recognized: " & Args(0)
  126. WScript.Echo "For help, just type ""Cscript.exe adsutil.vbs""."
  127. Result = GENERAL_FAILURE
  128. End Select
  129. WScript.Quit (Result)
  130. ''''''''''
  131. ' End Main
  132. ''''''''''
  133. ''''''''''''''''''''''''''''
  134. '
  135. ' Display Help Message
  136. '
  137. ''''''''''''''''''''''''''''
  138. Sub DisplayHelpMessage()
  139. WScript.Echo
  140. WScript.Echo "Usage:"
  141. WScript.Echo " ADSUTIL.VBS <cmd> [<path> [<value>]]"
  142. WScript.Echo
  143. 'WScript.Echo "Note: ADSUTIL only supports the ""no switch"" option of MDUTIL"
  144. 'WScript.Echo
  145. WScript.Echo "Description:"
  146. WScript.Echo "IIS administration utility that enables the configuration of metabase properties."
  147. WScript.Echo
  148. 'WScript.Echo "Supported MDUTIL Commands:"
  149. WScript.Echo "Supported Commands:"
  150. WScript.Echo " GET, SET, ENUM, DELETE, CREATE, COPY, "
  151. WScript.Echo " APPCREATEINPROC, APPCREATEOUTPROC, APPCREATEPOOLPROC, APPDELETE, APPUNLOAD, APPGETSTATUS "
  152. WScript.Echo
  153. WScript.Echo "Samples:"
  154. WScript.Echo " adsutil.vbs GET W3SVC/1/ServerBindings"
  155. WScript.Echo " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
  156. WScript.Echo " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
  157. WScript.Echo " adsutil.vbs START_SERVER W3SVC/1"
  158. WScript.Echo " adsutil.vbs ENUM /P W3SVC"
  159. WScript.Echo
  160. WScript.Echo "For Extended Help type:"
  161. WScript.Echo " adsutil.vbs HELP"
  162. End Sub
  163. ''''''''''''''''''''''''''''
  164. '
  165. ' Display Help Message
  166. '
  167. ''''''''''''''''''''''''''''
  168. Sub DisplayHelpMessageEx()
  169. WScript.Echo
  170. WScript.Echo "Usage:"
  171. WScript.Echo " ADSUTIL.VBS CMD [param param]"
  172. WScript.Echo
  173. 'WScript.Echo "Note: ADSUTIL only supports the ""no switch"" option of MDUTIL"
  174. 'WScript.Echo
  175. WScript.Echo "Description:"
  176. WScript.Echo "IIS K2 administration utility that enables the manipulation with ADSI parameters"
  177. WScript.Echo
  178. 'WScript.Echo "Standard MDUTIL Commands:"
  179. WScript.Echo "Standard Commands:"
  180. WScript.Echo " adsutil.vbs GET path - display chosen parameter"
  181. WScript.Echo " adsutil.vbs SET path value ... - assign the new value"
  182. WScript.Echo " adsutil.vbs ENUM path [""/P"" ] - enumerate all parameters for given path"
  183. WScript.Echo " adsutil.vbs DELETE path - delete given path or parameter"
  184. WScript.Echo " adsutil.vbs CREATE path [KeyType] - create given path and assigns it the given KeyType"
  185. WScript.Echo
  186. WScript.Echo " adsutil.vbs APPCREATEINPROC w3svc/1/root - Create an in-proc application"
  187. WScript.Echo " adsutil.vbs APPCREATEOUTPROC w3svc/1/root - Create an out-proc application"
  188. WScript.Echo " adsutil.vbs APPCREATEPOOLPROC w3svc/1/root- Create a pooled-proc application"
  189. WScript.Echo " adsutil.vbs APPDELETE w3svc/1/root - Delete the application if there is one"
  190. WScript.Echo " adsutil.vbs APPUNLOAD w3svc/1/root - Unload an application from w3svc runtime lookup table."
  191. WScript.Echo " adsutil.vbs APPDISABLE w3svc/1/root - Disable an application - appropriate for porting to another machine."
  192. WScript.Echo " adsutil.vbs APPENABLE w3svc/1/root - Enable an application - appropriate for importing from another machine."
  193. WScript.Echo " adsutil.vbs APPGETSTATUS w3svc/1/root - Get status of the application"
  194. WScript.Echo
  195. WScript.Echo "New ADSI Options:"
  196. WScript.Echo " /P - Valid for ENUM only. Enumerates the paths only (no data)"
  197. WScript.Echo " KeyType - Valide for CREATE only. Assigns the valid KeyType to the path"
  198. WScript.Echo
  199. WScript.Echo "Extended ADSUTIL Commands:"
  200. WScript.Echo " adsutil.vbs FIND path - find the paths where a given parameter is set"
  201. WScript.Echo " adsutil.vbs CREATE_VDIR path - create given path as a Virtual Directory"
  202. WScript.Echo " adsutil.vbs CREATE_VSERV path - create given path as a Virtual Server"
  203. WScript.Echo " adsutil.vbs START_SERVER path - starts the given web site"
  204. WScript.Echo " adsutil.vbs STOP_SERVER path - stops the given web site"
  205. WScript.Echo " adsutil.vbs PAUSE_SERVER path - pauses the given web site"
  206. WScript.Echo " adsutil.vbs CONTINUE_SERVER path - continues the given web site"
  207. WScript.Echo
  208. WScript.Echo
  209. WScript.Echo "Samples:"
  210. WScript.Echo " adsutil.vbs GET W3SVC/1/ServerBindings"
  211. WScript.Echo " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
  212. WScript.Echo " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
  213. WScript.Echo " adsutil.vbs START_SERVER W3SVC/1"
  214. WScript.Echo " adsutil.vbs ENUM /P W3SVC"
  215. WScript.Echo "Extended ADSUTIL Commands:"
  216. WScript.Echo " adsutil.vbs FIND path - find the paths where a given parameter is set"
  217. WScript.Echo " adsutil.vbs CREATE_VDIR path - create given path as a Virtual Directory"
  218. WScript.Echo " adsutil.vbs CREATE_VSERV path - create given path as a Virtual Server"
  219. WScript.Echo " adsutil.vbs START_SERVER path - starts the given web site"
  220. WScript.Echo " adsutil.vbs STOP_SERVER path - stops the given web site"
  221. WScript.Echo " adsutil.vbs PAUSE_SERVER path - pauses the given web site"
  222. WScript.Echo " adsutil.vbs CONTINUE_SERVER path - continues the given web site"
  223. WScript.Echo
  224. WScript.Echo
  225. WScript.Echo "Samples:"
  226. WScript.Echo " adsutil.vbs GET W3SVC/1/ServerBindings"
  227. WScript.Echo " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
  228. WScript.Echo " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
  229. WScript.Echo " adsutil.vbs START_SERVER W3SVC/1"
  230. WScript.Echo " adsutil.vbs ENUM /P W3SVC"
  231. ' adsutil.vbs ENUM_ALL path - recursively enumerate all parameters
  232. ' adsutil.vbs COPY pathsrc pathdst - copy all from pathsrc to pathdst (will create pathdst)
  233. ' adsutil.vbs SCRIPT scriptname - runs the script
  234. ' -path has format: {computer}/{service}/{instance}/{URL}/{Parameter}
  235. End Sub
  236. '''''''''''''''''''''''''''
  237. '
  238. ' DetectExeType
  239. '
  240. ' This can detect the type of exe the
  241. ' script is running under and warns the
  242. ' user of the popups.
  243. '
  244. '''''''''''''''''''''''''''
  245. Sub DetectExeType()
  246. Dim ScriptHost
  247. Dim ShellObject
  248. Dim CurrentPathExt
  249. Dim EnvObject
  250. Dim RegCScript
  251. Dim RegPopupType ' This is used to set the pop-up box flags.
  252. ' I couldn't find the pre-defined names
  253. RegPopupType = 32 + 4
  254. On Error Resume Next
  255. ScriptHost = WScript.FullName
  256. ScriptHost = Right(ScriptHost, Len(ScriptHost) - InStrRev(ScriptHost, "\"))
  257. If (UCase(ScriptHost) = "WSCRIPT.EXE") Then
  258. WScript.Echo ("This script does not work with WScript.")
  259. ' Create a pop-up box and ask if they want to register cscript as the default host.
  260. Set ShellObject = WScript.CreateObject("WScript.Shell")
  261. ' -1 is the time to wait. 0 means wait forever.
  262. RegCScript = ShellObject.PopUp("Would you like to register CScript as your default host for VBscript?", 0, "Register CScript", RegPopupType)
  263. If (Err.Number <> 0) Then
  264. ReportError ()
  265. WScript.Echo "To run this script using CScript, type: ""CScript.exe " & WScript.ScriptName & """"
  266. WScript.Quit (GENERAL_FAILURE)
  267. WScript.Quit (Err.Number)
  268. End If
  269. ' Check to see if the user pressed yes or no. Yes is 6, no is 7
  270. If (RegCScript = 6) Then
  271. ShellObject.RegWrite "HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
  272. ShellObject.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
  273. ' Check if PathExt already existed
  274. CurrentPathExt = ShellObject.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT")
  275. If Err.Number = &H80070002 Then
  276. Err.Clear
  277. Set EnvObject = ShellObject.Environment("PROCESS")
  278. CurrentPathExt = EnvObject.Item("PATHEXT")
  279. End If
  280. ShellObject.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT", CurrentPathExt & ";.VBS", "REG_SZ"
  281. If (Err.Number <> 0) Then
  282. ReportError ()
  283. WScript.Echo "Error Trying to write the registry settings!"
  284. WScript.Quit (Err.Number)
  285. Else
  286. WScript.Echo "Successfully registered CScript"
  287. End If
  288. Else
  289. WScript.Echo "To run this script type: ""CScript.Exe adsutil.vbs <cmd> <params>"""
  290. End If
  291. Dim ProcString
  292. Dim ArgIndex
  293. Dim ArgObj
  294. Dim Result
  295. ProcString = "Cscript //nologo " & WScript.ScriptFullName
  296. Set ArgObj = WScript.Arguments
  297. For ArgIndex = 0 To ArgCount - 1
  298. ProcString = ProcString & " " & Args(ArgIndex)
  299. Next
  300. 'Now, run the original executable under CScript.exe
  301. Result = ShellObject.Run(ProcString, 0, True)
  302. WScript.Quit (Result)
  303. End If
  304. End Sub
  305. ''''''''''''''''''''''''''
  306. '
  307. ' SetCommand Function
  308. '
  309. ' Sets the value of a property in the metabase.
  310. '
  311. ''''''''''''''''''''''''''
  312. Function SetCommand()
  313. Dim IIsObject
  314. Dim IIsObjectPath
  315. Dim IIsSchemaObject
  316. Dim IIsSchemaPath
  317. Dim ObjectPath
  318. Dim ObjectParameter
  319. Dim MachineName
  320. Dim ValueIndex
  321. Dim ValueList
  322. Dim ValueDisplay
  323. Dim ValueDisplayLen
  324. Dim ValueDataType
  325. Dim ValueData
  326. Dim ObjectDataType
  327. On Error Resume Next
  328. SetCommand = 0 ' Assume Success
  329. If ArgCount < 3 Then
  330. WScript.Echo "Error: Wrong number of Args for the SET command"
  331. WScript.Quit (GENERAL_FAILURE)
  332. End If
  333. ObjectPath = Args(1)
  334. SanitizePath ObjectPath
  335. MachineName = SeparateMachineName(ObjectPath)
  336. ObjectParameter = SplitParam(ObjectPath)
  337. ' Some Property Types have special needs - like ServerCommand.
  338. ' Check to see if this is a special command. If it is, then process it special.
  339. If (IsSpecialSetProperty(ObjectParameter)) Then
  340. SetCommand = DoSpecialSetProp(ObjectPath, ObjectParameter, MachineName)
  341. Exit Function
  342. End If
  343. If ObjectPath = "" Then
  344. IIsObjectPath = "IIS://" & MachineName
  345. Else
  346. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  347. End If
  348. Set IIsObject = GetObject(IIsObjectPath)
  349. If (Err.Number <> 0) Then
  350. ReportError ()
  351. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  352. WScript.Quit (Err.Number)
  353. End If
  354. ' Get the Schema of the property and determine if it's multivalued
  355. IIsSchemaPath = "IIS://" & MachineName & "/Schema/" & ObjectParameter
  356. Set IIsSchemaObject = GetObject(IIsSchemaPath)
  357. If (Err.Number <> 0) Then
  358. ReportError ()
  359. WScript.Echo "Error Trying To GET the Schema of the property: " & IIsSchemaPath
  360. WScript.Quit (Err.Number)
  361. End If
  362. ObjectDataType = UCase(IIsSchemaObject.Syntax)
  363. SanitizePath ObjectDataType
  364. Select Case (ObjectDataType)
  365. Case "STRING"
  366. ValueList = Args(2)
  367. IIsObject.Put ObjectParameter, (ValueList)
  368. Case "EXPANDSZ"
  369. ValueList = Args(2)
  370. IIsObject.Put ObjectParameter, (ValueList)
  371. Case "INTEGER"
  372. ' Added to convert hex values to integers
  373. ValueData = Args(2)
  374. If (UCase(Left(ValueData, 2))) = "0X" Then
  375. ValueData = "&h" & Right(ValueData, Len(ValueData) - 2)
  376. End If
  377. ValueList = CLng(ValueData)
  378. IIsObject.Put ObjectParameter, (ValueList)
  379. Case "BOOLEAN"
  380. ValueList = CBool(Args(2))
  381. IIsObject.Put ObjectParameter, (ValueList)
  382. Case "LIST"
  383. ReDim ValueList(ArgCount - 3)
  384. For ValueIndex = 2 To ArgCount - 1
  385. ValueList(ValueIndex - 2) = Args(ValueIndex)
  386. Next
  387. IIsObject.Put ObjectParameter, (ValueList)
  388. Case Else
  389. WScript.Echo "Error: Unknown data type in schema: " & IIsSchemaObject.Syntax
  390. End Select
  391. IIsObject.Setinfo
  392. If (Err.Number <> 0) Then
  393. ReportError ()
  394. WScript.Echo "Error Trying To SET the Property: " & ObjectParameter
  395. WScript.Quit (Err.Number)
  396. End If
  397. ' The function call succeeded, so display the output
  398. ' Set up the initial part of the display - the property name and data type
  399. ValueDisplay = ObjectParameter
  400. ValueDisplayLen = Len(ValueDisplay)
  401. If (ValueDisplayLen < SpacerSize) Then
  402. 'ValueDisplay = ValueDisplay & (Right (Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & TypeName (ValueList) & ") "
  403. ValueDisplay = ValueDisplay & (Right(Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & ObjectDataType & ") "
  404. Else
  405. ValueDisplay = ValueDisplay & ": " & "(" & TypeName(ValueList) & ") "
  406. End If
  407. ' Create the rest of the display - The actual data
  408. If (IIsSchemaObject.MultiValued) Then
  409. For ValueIndex = 0 To UBound(ValueList)
  410. 'WScript.Echo """" & ValueList(ValueIndex) & """"
  411. ValueDisplay = ValueDisplay & """" & ValueList(ValueIndex) & """ "
  412. Next
  413. Else
  414. If (UCase(IIsSchemaObject.Syntax) = "STRING") Then
  415. 'WScript.Echo """" & ValueList & """"
  416. If (IsSecureProperty(ObjectParameter,MachineName) = True) Then
  417. ValueDisplay = ValueDisplay & """" & "**********" & """"
  418. Else
  419. ValueDisplay = ValueDisplay & """" & ValueList & """"
  420. End If
  421. Else
  422. 'WScript.Echo ValueList
  423. ValueDisplay = ValueDisplay & ValueList
  424. End If
  425. End If
  426. ' Display the output
  427. WScript.Echo ValueDisplay
  428. SetCommand = 0 ' Success
  429. End Function
  430. ''''''''''''''''''''''''''
  431. '
  432. ' GetCommand Function
  433. '
  434. ' Gets the value of a property in the metabase.
  435. '
  436. ''''''''''''''''''''''''''
  437. Function GetCommand()
  438. Dim IIsObject
  439. Dim IIsObjectPath
  440. Dim IIsSchemaObject
  441. Dim IIsSchemaPath
  442. Dim ObjectPath
  443. Dim ObjectParameter
  444. Dim MachineName
  445. Dim ValueIndex
  446. Dim ValueList
  447. Dim ValueListArray
  448. Dim ValueDisplay
  449. Dim ValueDisplayLen
  450. Dim NewObjectparameter
  451. Dim DataPathList
  452. Dim DataPath
  453. On Error Resume Next
  454. GetCommand = 0 ' Assume Success
  455. If ArgCount <> 2 Then
  456. WScript.Echo "Error: Wrong number of Args for the GET command"
  457. WScript.Quit (GENERAL_FAILURE)
  458. End If
  459. ObjectPath = Args(1)
  460. SanitizePath ObjectPath
  461. MachineName = SeparateMachineName(ObjectPath)
  462. ObjectParameter = SplitParam(ObjectPath)
  463. NewObjectparameter = MapSpecGetParamName(ObjectParameter)
  464. ObjectParameter = NewObjectparameter
  465. If (IsSpecialGetProperty(ObjectParameter)) Then
  466. GetCommand = DoSpecialGetProp(ObjectPath, ObjectParameter, MachineName)
  467. Exit Function
  468. End If
  469. If ObjectPath = "" Then
  470. IIsObjectPath = "IIS://" & MachineName
  471. Else
  472. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  473. End If
  474. Set IIsObject = GetObject(IIsObjectPath)
  475. If (Err.Number <> 0) Then
  476. ReportError ()
  477. WScript.Echo "Error Trying To GET the Object (GetObject Failed): " & ObjectPath
  478. WScript.Quit (Err.Number)
  479. End If
  480. ' Get the Schema of the property and determine if it's multivalued
  481. IIsSchemaPath = "IIS://" & MachineName & "/Schema/" & ObjectParameter
  482. Set IIsSchemaObject = GetObject(IIsSchemaPath)
  483. If (Err.Number <> 0) Then
  484. ReportError ()
  485. WScript.Echo "Error Trying To GET the Schema of the property: " & IIsSchemaPath
  486. WScript.Quit (Err.Number)
  487. End If
  488. ' First, attempt to retrieve the property - this will tell us
  489. ' if you are even allowed to set the property at this node.
  490. ' Retrieve the property
  491. ValueList = IIsObject.Get(ObjectParameter)
  492. If (Err.Number <> 0) Then
  493. ReportError ()
  494. WScript.Echo "Error Trying To GET the property: (Get Method Failed) " & ObjectParameter
  495. WScript.Echo " (This property is probably not allowed at this node)"
  496. WScript.Quit (Err.Number)
  497. End If
  498. ' Test to see if the property is ACTUALLY set at this node
  499. DataPathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_INHERIT)
  500. If Err.Number <> 0 Then DataPathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_NO_INHERIT)
  501. Err.Clear
  502. ' If the data is not set anywhere, then stop the madness
  503. If (UBound(DataPathList) < 0) Then
  504. WScript.Echo "The parameter """ & ObjectParameter & """ is not set at this node."
  505. WScript.Quit (&H80005006) ' end with property not set error
  506. End If
  507. DataPath = DataPathList(0)
  508. SanitizePath DataPath
  509. ' Test to see if the item is actually set HERE
  510. If UCase(DataPath) <> UCase(IIsObjectPath) Then
  511. WScript.Echo "The parameter """ & ObjectParameter & """ is not set at this node."
  512. WScript.Quit (&H80005006) ' end with property not set error
  513. End If
  514. ' Set up the initial part of the display - the property name and data type
  515. ValueDisplay = ObjectParameter
  516. ValueDisplayLen = Len(ValueDisplay)
  517. If (ValueDisplayLen < SpacerSize) Then
  518. 'ValueDisplay = ValueDisplay & (Right (Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & TypeName (ValueList) & ") "
  519. ValueDisplay = ValueDisplay & (Right(Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & UCase(IIsSchemaObject.Syntax) & ") "
  520. Else
  521. ValueDisplay = ValueDisplay & ": " & "(" & TypeName(ValueList) & ") "
  522. End If
  523. ' Create the rest of the display - The actual data
  524. If (IIsSchemaObject.MultiValued) Then
  525. WScript.Echo ValueDisplay & " (" & UBound (ValueList) + 1 & " Items)"
  526. For ValueIndex = 0 To UBound(ValueList)
  527. WScript.Echo " """ & ValueList(ValueIndex) & """"
  528. 'ValueDisplay = ValueDisplay & """" & ValueList(ValueIndex) & """ "
  529. Next
  530. Else
  531. If (UCase(IIsSchemaObject.Syntax) = "STRING") Then
  532. If (IsSecureProperty(ObjectParameter,MachineName) = True) Then
  533. ValueDisplay = ValueDisplay & """" & "**********" & """"
  534. Else
  535. ValueDisplay = ValueDisplay & """" & ValueList & """"
  536. End If
  537. Elseif (UCase(IIsSchemaObject.Syntax) = "BINARY") Then
  538. ValueListArray = IIsObject.Get(ObjectParameter)
  539. ValueList = "0x"
  540. For ValueIndex = 0 To UBound(ValueListArray)
  541. ValueList = ValueList & ValueListArray(ValueIndex) & " "
  542. Next
  543. ValueDisplay = ValueDisplay & ValueList
  544. Else
  545. 'WScript.Echo ValueList
  546. ValueDisplay = ValueDisplay & ValueList
  547. End If
  548. ' Display the output
  549. WScript.Echo ValueDisplay
  550. End If
  551. If (Err.Number <> 0) Then
  552. ReportError ()
  553. WScript.Echo "Error Trying To GET the Property: " & ObjectParameter
  554. WScript.Quit (Err.Number)
  555. End If
  556. GetCommand = 0 ' Success
  557. End Function
  558. ''''''''''''''''''''''''''
  559. '
  560. ' EnumCommand Function
  561. '
  562. ' Enumerates all properties at a path in the metabase.
  563. '
  564. ''''''''''''''''''''''''''
  565. Function EnumCommand(Recurse, StartPath)
  566. On Error Resume Next
  567. Dim IIsObject
  568. Dim IIsObjectPath
  569. Dim IIsSchemaObject
  570. Dim IIsSchemaPath
  571. Dim ObjectPath
  572. Dim MachineName
  573. Dim ValueIndex
  574. Dim ValueList
  575. Dim ValueListArray
  576. Dim ValueString
  577. Dim PropertyName
  578. Dim PropertyAttribObj
  579. Dim PropertyListSet
  580. Dim PropertyList
  581. Dim PropertyObjPath
  582. Dim PropertyObject
  583. Dim ChildObject
  584. Dim ChildObjectName
  585. Dim EnumPathsOnly
  586. Dim EnumAllData
  587. Dim ErrMask
  588. Dim IsInherit
  589. Dim PropertyDataType
  590. Dim SpecialResult
  591. Dim PathOnlyOption
  592. PathOnlyOption = "/P"
  593. EnumCommand = 0 ' Assume Success
  594. EnumPathsOnly = False ' Assume that the user wants all of the data items
  595. EnumAllData = False ' Assume that the user wants only the actual data items
  596. If (ArgCount = 1) Then
  597. ObjectPath = ""
  598. EnumPathsOnly = False
  599. ArgCount = 2
  600. ElseIf (ArgCount = 2) Then
  601. If UCase(Args(1)) = PathOnlyOption Then
  602. ObjectPath = ""
  603. EnumPathsOnly = True
  604. Else
  605. ObjectPath = Args(1)
  606. EnumPathsOnly = False
  607. End If
  608. ElseIf (ArgCount = 3) Then
  609. If UCase(Args(1)) = PathOnlyOption Then
  610. ObjectPath = Args(2)
  611. EnumPathsOnly = True
  612. ElseIf UCase(Args(2)) = PathOnlyOption Then
  613. ObjectPath = Args(1)
  614. EnumPathsOnly = True
  615. Else
  616. WScript.Echo "Error: Invalid arguments for the ENUM command"
  617. WScript.Quit (GENERAL_FAILURE)
  618. End If
  619. Else
  620. WScript.Echo "Error: Wrong number of Args for the ENUM command"
  621. WScript.Quit (GENERAL_FAILURE)
  622. End If
  623. If StartPath <> "" Then ObjectPath = StartPath
  624. SanitizePath ObjectPath
  625. MachineName = SeparateMachineName(ObjectPath)
  626. IIsObjectPath = "IIS://" & MachineName
  627. If (ObjectPath <> "") Then
  628. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  629. End If
  630. Set IIsObject = GetObject(IIsObjectPath)
  631. If (Err.Number <> 0) Then
  632. WScript.Echo
  633. ReportError ()
  634. WScript.Echo "Error Trying To ENUM the Object (GetObject Failed): " & ObjectPath
  635. WScript.Quit (Err.Number)
  636. End If
  637. ' Get the Schema of the object and enumerate through all of the properties
  638. IIsSchemaPath = IIsObject.Schema
  639. Set IIsSchemaObject = GetObject(IIsSchemaPath)
  640. If (Err.Number <> 0) Then
  641. WScript.Echo
  642. ReportError ()
  643. WScript.Echo "Error Trying To GET the Schema of the class: " & IIsSchemaPath
  644. WScript.Quit (Err.Number)
  645. End If
  646. ReDim PropertyListSet(1)
  647. PropertyListSet(0) = IIsSchemaObject.MandatoryProperties
  648. PropertyListSet(1) = IIsSchemaObject.OptionalProperties
  649. If (Err.Number <> 0) Then
  650. WScript.Echo
  651. ReportError ()
  652. WScript.Echo "Error trying to get the list of properties: " & IIsSchemaPath
  653. WScript.Quit (Err.Number)
  654. End If
  655. ' This now checks for an empty OptionalProperties list
  656. If TypeName (PropertyListSet(1)) <> "Variant()" Then
  657. WScript.Echo
  658. WScript.Echo "Warning: The optionalproperties list is of an invalid type"
  659. WScript.Echo
  660. ElseIf (UBound (PropertyListSet(1)) = -1) Then
  661. WScript.Echo
  662. WScript.Echo "Warning: The OptionalProperties list for this node is empty."
  663. WScript.Echo
  664. End If
  665. If (Not EnumPathsOnly) Then
  666. For Each PropertyList In PropertyListSet
  667. For Each PropertyName In PropertyList
  668. If Err <> 0 Then
  669. Exit For
  670. End If
  671. ' Test to see if the property is even set at this node
  672. IsInherit = False
  673. Err.Clear
  674. Set PropertyAttribObj = IIsObject.GetPropertyAttribObj(PropertyName)
  675. If (Err.Number = 0) Then
  676. If (PropertyAttribObj.IsInherit) Then
  677. IsInherit = True
  678. End If
  679. Err.Clear
  680. If (IsInherit = False) Or (EnumAllData) Then
  681. ' If the above statement is true, then the data exists here or the user wants it anyway.
  682. PropertyObjPath = "IIS://" & MachineName & "/Schema/" & PropertyName
  683. Set PropertyObject = GetObject(PropertyObjPath)
  684. If (Err.Number <> 0) Then
  685. WScript.Echo
  686. ReportError ()
  687. WScript.Echo "Error trying to enumerate the Optional properties (Couldn't Get Property Information): " & PropertyObjPath
  688. WScript.Echo "Last Property Name: " & PropertyName
  689. WScript.Echo "PropertyObjPath: " & PropertyObjPath
  690. 'WScript.Quit (Err.Number)
  691. WScript.Echo
  692. EnumCommand = Err.Number
  693. Err.Clear
  694. End If
  695. ValueList = ""
  696. ValueListArray = ""
  697. PropertyDataType = UCase(PropertyObject.Syntax)
  698. Select Case PropertyDataType
  699. Case "STRING"
  700. ValueList = IIsObject.Get(PropertyName)
  701. If (IsSecureProperty(PropertyName,MachineName) = True) Then
  702. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & """" & "**********" & """"
  703. Else
  704. If (Len(PropertyName) < SpacerSize) Then
  705. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") """ & ValueList & """"
  706. Else
  707. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ")" & """" & ValueList & """"
  708. End If
  709. End If
  710. Case "EXPANDSZ"
  711. ValueList = IIsObject.Get(PropertyName)
  712. If (Len(PropertyName) < SpacerSize) Then
  713. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") """ & ValueList & """"
  714. Else
  715. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") """ & ValueList & """"
  716. End If
  717. Case "BINARY"
  718. ValueListArray = IIsObject.Get(PropertyName)
  719. ValueList = "0x"
  720. For ValueIndex = 0 To UBound(ValueListArray)
  721. ValueList = ValueList & ValueListArray(ValueIndex) & " "
  722. Next
  723. If (Len(PropertyName) < SpacerSize) Then
  724. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & ValueList
  725. Else
  726. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & ValueList
  727. End If
  728. Case "INTEGER"
  729. ValueList = IIsObject.Get(PropertyName)
  730. If (Len(PropertyName) < SpacerSize) Then
  731. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & ValueList
  732. Else
  733. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & ValueList
  734. End If
  735. Case "BOOLEAN"
  736. ValueList = IIsObject.Get(PropertyName)
  737. If (Len(PropertyName) < SpacerSize) Then
  738. WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & ValueList
  739. Else
  740. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & ValueList
  741. End If
  742. Case "LIST"
  743. ValueList = IIsObject.Get(PropertyName)
  744. If (Len(PropertyName) < SpacerSize) Then
  745. WScript.Echo PropertyName & _
  746. Left(Spacer, Len(Spacer) - Len(PropertyName)) & _
  747. ": " & "(" & PropertyDataType & ") (" & _
  748. (UBound (ValueList) + 1) & " Items)"
  749. Else
  750. WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") (" & (UBound (ValueList) + 1) & " Items)"
  751. End If
  752. ValueString = ""
  753. For ValueIndex = 0 To UBound(ValueList)
  754. WScript.Echo " """ & ValueList(ValueIndex) & """"
  755. Next
  756. WScript.Echo
  757. Case Else
  758. If (IsSpecialGetProperty(PropertyName)) Then
  759. SpecialResult = DoSpecialGetProp(ObjectPath, PropertyName, MachineName)
  760. Err.Clear
  761. Else
  762. WScript.Echo
  763. WScript.Echo "DataType: " & """" & PropertyObject.Syntax & """" & " Not Yet Supported on property: " & PropertyName
  764. ReportError
  765. WScript.Echo
  766. End If
  767. End Select
  768. End If ' End if data exists at the current node
  769. Else ' Error during GetPropertyAttribObj
  770. Err.Clear 'ignore and go to the next property
  771. End If
  772. If (Err.Number <> 0) Then
  773. WScript.Echo
  774. ReportError ()
  775. WScript.Echo "Error trying to enumerate the Optional properties (Error trying to get property value): " & PropertyObjPath
  776. WScript.Echo "Last Property Name: " & PropertyName
  777. WScript.Echo "PropertyObjPath: " & PropertyObjPath
  778. ' If there is an ADS error, just ignore it and move on
  779. ' otherwise, quit
  780. If ((Err.Number) >= &H80005000) And ((Err.Number) < &H80006000) Then
  781. Err.Clear
  782. WScript.Echo "Continuing..."
  783. Else
  784. WScript.Quit (Err.Number)
  785. End If
  786. WScript.Echo
  787. End If
  788. Next
  789. Next
  790. If (Err.Number <> 0) Then
  791. WScript.Echo "Error trying to enumerate the properties lists:"
  792. ReportError ()
  793. WScript.Echo
  794. EnumCommand = Err.Number
  795. Err.Clear
  796. End If
  797. End If ' End if (Not EnumPathsOnly)
  798. 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
  799. ' Now, enumerate the data paths
  800. For Each ChildObject In IIsObject
  801. If (Err.Number <> 0) Then Exit For
  802. ChildObjectName = Right(ChildObject.AdsPath, Len(ChildObject.AdsPath) - 6)
  803. ChildObjectName = Right(ChildObjectName, Len(ChildObjectName) - InStr(ChildObjectName, "/") + 1)
  804. WScript.Echo "[" & ChildObjectName & "]"
  805. If (Recurse = True) And (ChildObjectName <> Args(1)) Then
  806. EnumCommand = EnumCommand(True, ChildObjectName)
  807. End If
  808. Next
  809. If (Err.Number <> 0) Then
  810. WScript.Echo "Error trying to enumerate the child nodes"
  811. ReportError ()
  812. WScript.Echo
  813. EnumCommand = Err.Number
  814. Err.Clear
  815. End If
  816. WScript.Echo ""
  817. End Function
  818. ''''''''''''''''''''''''''
  819. '
  820. ' Create Function
  821. '
  822. ' Creates a path in the metabase. An additional parameter that is
  823. ' not found in mdutil is optional. That is the Object Type (KeyType)
  824. ' If this is not specified, the object type will be assumed to be
  825. ' IIsObject (which, of course, is useless).
  826. '
  827. ''''''''''''''''''''''''''
  828. Function CreateCommand(ObjectTypeParam)
  829. On Error Resume Next
  830. Dim IIsObject
  831. Dim IIsObjectPath
  832. Dim IIsObjectRelativePath
  833. Dim NewObject
  834. Dim ObjectTypeName
  835. Dim ParentObjPath
  836. Dim ParentObjSize
  837. Dim FullAdsParentPath
  838. Dim MachineName
  839. Dim OpenErr
  840. ' Set the return code - assume success
  841. CreateCommand = 0
  842. ' Setup the parameters
  843. If (ArgCount = 2) Then
  844. If (ObjectTypeParam = "") Then
  845. ObjectTypeName = "IIsObject"
  846. Else
  847. ObjectTypeName = ObjectTypeParam
  848. End If
  849. ElseIf (ArgCount = 3) Then
  850. ObjectTypeName = Args(2)
  851. Else
  852. WScript.Echo "Error: Wrong number of Args for the CREATE command"
  853. DisplayHelpMessage
  854. WScript.Quit (GENERAL_FAILURE)
  855. End If
  856. IIsObjectPath = Args(1)
  857. SanitizePath IIsObjectPath
  858. MachineName = SeparateMachineName(IIsObjectPath)
  859. ' Parse the path and determine if the parent exists.
  860. ParentObjSize = InStrRev(IIsObjectPath, "/")
  861. ParentObjPath = ""
  862. If ParentObjSize <> 0 Then
  863. ParentObjPath = Left(IIsObjectPath, ParentObjSize - 1)
  864. IIsObjectRelativePath = Right(IIsObjectPath, Len(IIsObjectPath) - ParentObjSize)
  865. Else
  866. IIsObjectRelativePath = IIsObjectPath
  867. End If
  868. If ParentObjPath <> "" Then
  869. FullAdsParentPath = "IIS://" & MachineName & "/" & ParentObjPath
  870. Else
  871. FullAdsParentPath = "IIS://" & MachineName
  872. End If
  873. 'debug
  874. 'WScript.Echo "Last Error: " & Err.Number
  875. 'WScript.Echo "MachineName: " & MachineName
  876. 'WScript.Echo "ParentObjPath: " & ParentObjPath
  877. 'WScript.Echo "FullAdsParentPath: " & FullAdsParentPath
  878. 'WScript.Echo "IIsObjectPath: " & IIsObjectPath
  879. 'WScript.Echo "IIsObjectRelativePath: " & IIsObjectRelativePath
  880. 'WScript.Echo "ObjectTypeName: " & ObjectTypeName
  881. ' First, attempt to open the parent path and add the new path.
  882. Set IIsObject = GetObject(FullAdsParentPath)
  883. If Err.Number <> 0 Then
  884. OpenErr = Err.Number
  885. OpenErrDesc = Err.Description
  886. Err.Clear
  887. ' Attempt to get the Computer Object (IIS://LocalHost)
  888. Set IIsObject = GetObject("IIS://" & MachineName)
  889. If Err.Number <> 0 Then
  890. WScript.Echo
  891. ReportError ()
  892. WScript.Echo "Error accessing the object: " & IIsObjectPath
  893. WScript.Quit (Err.Number)
  894. End If
  895. End If
  896. 'Now, attempt to add the new object.
  897. If (OpenErr <> 0) Then
  898. Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectPath)
  899. Else
  900. Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectRelativePath)
  901. End If
  902. If Err.Number <> 0 Then
  903. WScript.Echo
  904. ReportError ()
  905. WScript.Echo "Error creating the object: " & IIsObjectPath
  906. WScript.Quit (Err.Number)
  907. End If
  908. NewObject.Setinfo
  909. If Err.Number <> 0 Then
  910. WScript.Echo
  911. ReportError ()
  912. WScript.Echo "Error creating the object: " & IIsObjectPath
  913. WScript.Quit (Err.Number)
  914. End If
  915. ' Now, if the parent object was not created, generate a warning.
  916. If OpenErr <> 0 Then
  917. WScript.Echo
  918. WScript.Echo "WARNING: The parent path (" & ParentObjPath & ") was not already created."
  919. WScript.Echo " This means that some of the intermediate objects will not have an accurate"
  920. WScript.Echo " Object Type. You should fix this by setting the KeyType on the intermediate"
  921. WScript.Echo " objects."
  922. WScript.Echo
  923. CreateCommand = GENERAL_WARNING
  924. End If
  925. If UCase(ObjectTypeName) = "IISOBJECT" Then
  926. WScript.Echo
  927. WScript.Echo "WARNING: The Object Type of this object was not specified or was specified as"
  928. WScript.Echo " IIsObject. This means that you will not be able to set or get properties"
  929. WScript.Echo " on the object until the KeyType property is set."
  930. WScript.Echo
  931. CreateCommand = GENERAL_WARNING
  932. End If
  933. WScript.Echo "created """ & IIsObjectPath & """"
  934. End Function
  935. ''''''''''''''''''''''''''
  936. '
  937. ' Delete Function
  938. '
  939. ' Deletes a path in the metabase.
  940. '
  941. ''''''''''''''''''''''''''
  942. Function DeleteCommand()
  943. On Error Resume Next
  944. Dim IIsObject
  945. Dim IIsObjectPath
  946. Dim ObjectPath
  947. Dim ObjectParam
  948. Dim MachineName
  949. Dim DummyVariant
  950. Dim DeletePathOnly
  951. ReDim DummyVariant(0)
  952. DummyVariant(0) = "Crap"
  953. ' Set the return code - assume success
  954. DeleteCommand = 0
  955. ' Setup the parameters
  956. If (ArgCount <> 2) Then
  957. WScript.Echo "Error: Wrong number of Args for the DELETE command"
  958. WScript.Quit (GENERAL_FAILURE)
  959. End If
  960. ObjectPath = Args(1)
  961. ' Check and see if the user is specifically asking to delete the path
  962. DeletePathOnly = False
  963. If Right(ObjectPath, 1) = "/" Then
  964. DeletePathOnly = True
  965. End If
  966. ' Sanitize the path and split parameter and path
  967. SanitizePath ObjectPath
  968. MachineName = SeparateMachineName(ObjectPath)
  969. ObjectParam = SplitParam(ObjectPath)
  970. ' Open the parent object
  971. IIsObjectPath = "IIS://" & MachineName
  972. If ObjectPath <> "" Then
  973. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  974. End If
  975. Set IIsObject = GetObject(IIsObjectPath)
  976. If Err.Number <> 0 Then
  977. WScript.Echo
  978. ReportError ()
  979. WScript.Echo "Error deleting the object: " & ObjectPath & "/" & ObjectParam
  980. WScript.Quit (Err.Number)
  981. End If
  982. ' If they did not specifically ask to delete the path, then attempt to delete the property
  983. If Not DeletePathOnly Then
  984. ' Try to delete the property
  985. ' ADS_PROPERTY_CLEAR used to be defined, but it isn't anymore.
  986. 'IIsObject.PutEx ADS_PROPERTY_CLEAR, ObjectParam, DummyVariant
  987. IIsObject.PutEx "1", ObjectParam, DummyVariant
  988. ' If it succeeded, then just return, else continue and try to delete the path
  989. If Err.Number = 0 Then
  990. WScript.Echo "deleted property """ & ObjectParam & """"
  991. Exit Function
  992. End If
  993. Err.Clear
  994. End If
  995. ' Try to just delete the path
  996. IIsObject.Delete "IIsObject", ObjectParam
  997. If Err.Number <> 0 Then
  998. WScript.Echo
  999. ReportError ()
  1000. WScript.Echo "Error deleting the object: " & ObjectPath & "/" & ObjectParam
  1001. WScript.Quit (Err.Number)
  1002. End If
  1003. WScript.Echo "deleted path """ & ObjectPath & "/" & ObjectParam & """"
  1004. Exit Function
  1005. End Function
  1006. ''''''''''''''''''''''''''
  1007. '
  1008. ' EnumAllCommand
  1009. '
  1010. ' Enumerates all data and all properties in the metabase under the current path.
  1011. '
  1012. ''''''''''''''''''''''''''
  1013. Function EnumAllCommand()
  1014. On Error Resume Next
  1015. WScript.Echo "ENUM_ALL Command not yet supported"
  1016. End Function
  1017. ''''''''''''''''''''''''''
  1018. '
  1019. ' CopyMoveCommand
  1020. '
  1021. ' Copies a path in the metabase to another path.
  1022. '
  1023. ''''''''''''''''''''''''''
  1024. Function CopyMoveCommand(bCopyFlag)
  1025. On Error Resume Next
  1026. Dim SrcObjectPath
  1027. Dim DestObjectPath
  1028. Dim DestObject
  1029. Dim ParentObjectPath
  1030. Dim ParentRelativePath
  1031. Dim ParentObject
  1032. Dim MachineName
  1033. Dim TmpDestLeftPath
  1034. Dim TmpSrcLeftPath
  1035. CopyMoveCommand = 0 ' Assume Success
  1036. If ArgCount <> 3 Then
  1037. WScript.Echo "Error: Wrong number of Args for the Copy/Move command"
  1038. WScript.Quit (GENERAL_FAILURE)
  1039. End If
  1040. SrcObjectPath = Args(1)
  1041. DestObjectPath = Args(2)
  1042. SanitizePath SrcObjectPath
  1043. SanitizePath DestObjectPath
  1044. MachineName = SeparateMachineName(SrcObjectPath)
  1045. ParentObjectPath = "IIS://" & MachineName
  1046. ' Extract the left part of the paths until there are no more left parts to extract
  1047. Do
  1048. TmpSrcLeftPath = SplitLeftPath(SrcObjectPath)
  1049. TmpDestLeftPath = SplitLeftPath(DestObjectPath)
  1050. If (SrcObjectPath = "") Or (DestObjectPath = "") Then
  1051. SrcObjectPath = TmpSrcLeftPath & "/" & SrcObjectPath
  1052. DestObjectPath = TmpDestLeftPath & "/" & DestObjectPath
  1053. Exit Do
  1054. End If
  1055. If (TmpSrcLeftPath <> TmpDestLeftPath) Then
  1056. SrcObjectPath = TmpSrcLeftPath & "/" & SrcObjectPath
  1057. DestObjectPath = TmpDestLeftPath & "/" & DestObjectPath
  1058. Exit Do
  1059. End If
  1060. ParentObjectPath = ParentObjectPath & "/" & TmpSrcLeftPath
  1061. ParentRelativePath = ParentRelativePath & "/" & TmpSrcLeftPath
  1062. Loop
  1063. SanitizePath SrcObjectPath
  1064. SanitizePath DestObjectPath
  1065. SanitizePath ParentObjectPath
  1066. ' Now, open the parent object and Copy/Move the objects
  1067. Set ParentObject = GetObject(ParentObjectPath)
  1068. If (Err.Number <> 0) Then
  1069. ReportError ()
  1070. WScript.Echo "Error trying to open the object: " & ParentObjectPath
  1071. WScript.Quit (Err.Number)
  1072. End If
  1073. If (bCopyFlag) Then
  1074. Set DestObject = ParentObject.CopyHere(SrcObjectPath, DestObjectPath)
  1075. Else
  1076. Set DestObject = ParentObject.MoveHere(SrcObjectPath, DestObjectPath)
  1077. End If
  1078. If (Err.Number <> 0) Then
  1079. ReportError ()
  1080. WScript.Echo "Error trying to Copy/Move Source to Dest."
  1081. WScript.Quit (Err.Number)
  1082. End If
  1083. If (bCopyFlag) Then
  1084. WScript.Echo "copied from " & ParentRelativePath & "/" & SrcObjectPath & " to " & ParentRelativePath & "/" & DestObjectPath
  1085. Else
  1086. WScript.Echo "moved from " & ParentRelativePath & "/" & SrcObjectPath & " to " & ParentRelativePath & "/" & DestObjectPath
  1087. End If
  1088. End Function
  1089. ''''''''''''''''''''''''''
  1090. '
  1091. ' StartServerCommand
  1092. '
  1093. ' Starts a server in the metabase.
  1094. '
  1095. ''''''''''''''''''''''''''
  1096. Function StartServerCommand()
  1097. On Error Resume Next
  1098. Dim IIsObject
  1099. Dim IIsObjectPath
  1100. Dim ObjectPath
  1101. Dim MachineName
  1102. If ArgCount <> 2 Then
  1103. WScript.Echo "Error: Wrong number of Args for the START_SERVER command"
  1104. WScript.Quit (GENERAL_FAILURE)
  1105. End If
  1106. ObjectPath = Args(1)
  1107. SanitizePath ObjectPath
  1108. MachineName = SeparateMachineName(ObjectPath)
  1109. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1110. Set IIsObject = GetObject(IIsObjectPath)
  1111. If (Err.Number <> 0) Then
  1112. ReportError ()
  1113. WScript.Echo "Error trying to open the object: " & ObjectPath
  1114. WScript.Quit (Err.Number)
  1115. End If
  1116. 'debug
  1117. 'WScript.echo "About to start server. Last Error: " & Err.Number
  1118. IIsObject.Start
  1119. 'WScript.echo "After starting server. Last Error: " & Err.Number
  1120. If (Err.Number <> 0) Then
  1121. ReportError ()
  1122. WScript.Echo "Error trying to START the server: " & ObjectPath
  1123. WScript.Quit (Err.Number)
  1124. End If
  1125. WScript.Echo "Server " & ObjectPath & " Successfully STARTED"
  1126. End Function
  1127. ''''''''''''''''''''''''''
  1128. '
  1129. ' StopServerCommand
  1130. '
  1131. ' Stops a server in the metabase.
  1132. '
  1133. ''''''''''''''''''''''''''
  1134. Function StopServerCommand()
  1135. On Error Resume Next
  1136. Dim IIsObject
  1137. Dim IIsObjectPath
  1138. Dim ObjectPath
  1139. Dim MachineName
  1140. If ArgCount <> 2 Then
  1141. WScript.Echo "Error: Wrong number of Args for the STOP_SERVER command"
  1142. WScript.Quit (GENERAL_FAILURE)
  1143. End If
  1144. ObjectPath = Args(1)
  1145. SanitizePath ObjectPath
  1146. MachineName = SeparateMachineName(ObjectPath)
  1147. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1148. Set IIsObject = GetObject(IIsObjectPath)
  1149. If (Err.Number <> 0) Then
  1150. ReportError ()
  1151. WScript.Echo "Error trying to open the object: " & ObjectPath
  1152. WScript.Quit (Err.Number)
  1153. End If
  1154. IIsObject.Stop
  1155. If (Err.Number <> 0) Then
  1156. ReportError ()
  1157. WScript.Echo "Error trying to STOP the server: " & ObjectPath
  1158. WScript.Quit (Err.Number)
  1159. End If
  1160. WScript.Echo "Server " & ObjectPath & " Successfully STOPPED"
  1161. End Function
  1162. ''''''''''''''''''''''''''
  1163. '
  1164. ' PauseServerCommand
  1165. '
  1166. ' Pauses a server in the metabase.
  1167. '
  1168. ''''''''''''''''''''''''''
  1169. Function PauseServerCommand()
  1170. On Error Resume Next
  1171. Dim IIsObject
  1172. Dim IIsObjectPath
  1173. Dim ObjectPath
  1174. Dim MachineName
  1175. If ArgCount <> 2 Then
  1176. WScript.Echo "Error: Wrong number of Args for the PAUSE_SERVER command"
  1177. WScript.Quit (GENERAL_FAILURE)
  1178. End If
  1179. ObjectPath = Args(1)
  1180. SanitizePath ObjectPath
  1181. MachineName = SeparateMachineName(ObjectPath)
  1182. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1183. Set IIsObject = GetObject(IIsObjectPath)
  1184. If (Err.Number <> 0) Then
  1185. ReportError ()
  1186. WScript.Echo "Error trying to open the object: " & ObjectPath
  1187. WScript.Quit (Err.Number)
  1188. End If
  1189. IIsObject.Pause
  1190. If (Err.Number <> 0) Then
  1191. ReportError ()
  1192. WScript.Echo "Error trying to PAUSE the server: " & ObjectPath
  1193. WScript.Quit (Err.Number)
  1194. End If
  1195. WScript.Echo "Server " & ObjectPath & " Successfully PAUSED"
  1196. End Function
  1197. ''''''''''''''''''''''''''
  1198. '
  1199. ' ContinueServerCommand
  1200. '
  1201. ' Continues a server in the metabase.
  1202. '
  1203. ''''''''''''''''''''''''''
  1204. Function ContinueServerCommand()
  1205. On Error Resume Next
  1206. Dim IIsObject
  1207. Dim IIsObjectPath
  1208. Dim ObjectPath
  1209. Dim MachineName
  1210. If ArgCount <> 2 Then
  1211. WScript.Echo "Error: Wrong number of Args for the CONTINUE_SERVER command"
  1212. WScript.Quit (GENERAL_FAILURE)
  1213. End If
  1214. ObjectPath = Args(1)
  1215. SanitizePath ObjectPath
  1216. MachineName = SeparateMachineName(ObjectPath)
  1217. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1218. Set IIsObject = GetObject(IIsObjectPath)
  1219. If (Err.Number <> 0) Then
  1220. ReportError ()
  1221. WScript.Echo "Error trying to open the object: " & ObjectPath
  1222. WScript.Quit (Err.Number)
  1223. End If
  1224. IIsObject.Continue
  1225. If (Err.Number <> 0) Then
  1226. ReportError ()
  1227. WScript.Echo "Error trying to CONTINUE the server: " & ObjectPath
  1228. WScript.Quit (Err.Number)
  1229. End If
  1230. WScript.Echo "Server " & ObjectPath & " Successfully CONTINUED"
  1231. End Function
  1232. Function FindData()
  1233. ' FindData will accept 1 parameter from the command line - the node and
  1234. ' property to search for (i.e. w3svc/1/ServerComment)
  1235. On Error Resume Next
  1236. Dim ObjectPath
  1237. Dim ObjectParameter
  1238. Dim NewObjectparameter
  1239. Dim MachineName
  1240. Dim IIsObjectPath
  1241. Dim IIsObject
  1242. Dim Path
  1243. Dim PathList
  1244. Dim I
  1245. FindData = 0 ' Assume Success
  1246. If ArgCount <> 2 Then
  1247. WScript.Echo "Error: Wrong number of Args for the FIND_DATA command"
  1248. WScript.Quit (GENERAL_FAILURE)
  1249. End If
  1250. ObjectPath = Args(1)
  1251. SanitizePath ObjectPath
  1252. MachineName = SeparateMachineName(ObjectPath)
  1253. ObjectParameter = SplitParam(ObjectPath)
  1254. ' Since people may still want to use MDUTIL parameter names
  1255. ' we should still do the GET translation of parameter names.
  1256. NewObjectparameter = MapSpecGetParamName(ObjectParameter)
  1257. ObjectParameter = NewObjectparameter
  1258. If ObjectPath = "" Then
  1259. IIsObjectPath = "IIS://" & MachineName
  1260. Else
  1261. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1262. End If
  1263. Set IIsObject = GetObject(IIsObjectPath)
  1264. If (Err.Number <> 0) Then
  1265. ReportError ()
  1266. WScript.Echo "Error trying to find data paths for the Object (GetObject Failed): " & ObjectPath
  1267. WScript.Quit (Err.Number)
  1268. End If
  1269. ' Now, list out all the places where this property exists.
  1270. PathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_INHERIT)
  1271. If Err.Number <> 0 Then PathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_NO_INHERIT)
  1272. If (Err.Number <> 0) Then
  1273. ReportError ()
  1274. WScript.Echo "Error trying to get a path list (GetDataPaths Failed): " & ObjectPath
  1275. WScript.Quit (Err.Number)
  1276. End If
  1277. If UBound(PathList) < 0 Then
  1278. WScript.Echo "Property " & ObjectParameter & " was not found at any node beneath " & ObjectPath
  1279. Else
  1280. WScript.Echo "Property " & ObjectParameter & " found at:"
  1281. For Each Path In PathList
  1282. Path = Right(Path, Len(Path) - 6)
  1283. Path = Right(Path, Len(Path) - InStr(Path, "/"))
  1284. WScript.Echo " " & Path
  1285. Next
  1286. End If
  1287. If (Err.Number <> 0) Then
  1288. ReportError ()
  1289. WScript.Echo "Error listing the data paths (_newEnum Failed): " & ObjectPath
  1290. WScript.Quit (Err.Number)
  1291. End If
  1292. End Function
  1293. '''''''''''''''''''''
  1294. '
  1295. ' MimeMapGet
  1296. '
  1297. ' Special function for displaying a MimeMap property
  1298. '
  1299. '''''''''''''''''''''
  1300. Function MimeMapGet(ObjectPath, MachineName)
  1301. On Error Resume Next
  1302. Dim MimePath
  1303. Dim MimeMapList
  1304. Dim MimeMapObject
  1305. Dim MimeEntry
  1306. Dim MimeEntryIndex
  1307. Dim MimeStr
  1308. Dim MimeOutPutStr
  1309. Dim DataPathList
  1310. Dim DataPath
  1311. MimeMapGet = 0 ' Assume Success
  1312. MimePath = "IIS://" & MachineName
  1313. If ObjectPath <> "" Then MimePath = MimePath & "/" & ObjectPath
  1314. ' Get the object that contains the mimemap
  1315. Set MimeMapObject = GetObject(MimePath)
  1316. If (Err.Number <> 0) Then
  1317. ReportError ()
  1318. WScript.Echo "Error trying to get the Object: " & ObjectPath
  1319. WScript.Quit (Err.Number)
  1320. End If
  1321. ' Test to see if the property is ACTUALLY set at this node
  1322. DataPathList = MimeMapObject.GetDataPaths("MimeMap", IIS_DATA_INHERIT)
  1323. If Err.Number <> 0 Then DataPathList = IIsObject.GetDataPaths(MimeMap, IIS_DATA_NO_INHERIT)
  1324. Err.Clear
  1325. ' If the data is not set anywhere, then stop the madness
  1326. If (UBound(DataPathList) < 0) Then
  1327. MimeMapGet = &H80005006 ' end with property not set error
  1328. Exit Function
  1329. End If
  1330. DataPath = DataPathList(0)
  1331. SanitizePath DataPath
  1332. ' Test to see if the item is actually set HERE
  1333. If UCase(DataPath) <> UCase(MimePath) Then
  1334. MimeMapGet = &H80005006 ' end with property not set error
  1335. Exit Function
  1336. End If
  1337. ' Get the mime map list from the object
  1338. MimeMapList = MimeMapObject.Get("MimeMap")
  1339. If (Err.Number <> 0) Then
  1340. ReportError ()
  1341. WScript.Echo "Error trying to get the Object: " & ObjectPath
  1342. WScript.Quit (Err.Number)
  1343. End If
  1344. MimeOutPutStr = "MimeMap : (MimeMapList) "
  1345. ' Enumerate the Mime Entries
  1346. For MimeEntryIndex = 0 To UBound(MimeMapList)
  1347. Set MimeEntry = MimeMapList(MimeEntryIndex)
  1348. MimeOutPutStr = MimeOutPutStr & """" & MimeEntry.Extension & "," & MimeEntry.MimeType & """ "
  1349. Next
  1350. If (Err.Number <> 0) Then
  1351. ReportError ()
  1352. WScript.Echo "Error trying to Create the Mime Map List."
  1353. WScript.Quit (Err.Number)
  1354. End If
  1355. WScript.Echo MimeOutPutStr
  1356. End Function
  1357. Function MimeMapSet(ObjectPath, ObjectParameter, MachineName)
  1358. On Error Resume Next
  1359. Dim MimePath
  1360. Dim MimeEntryIndex
  1361. Dim MimeMapList()
  1362. Dim MimeMapObject
  1363. Dim MimeEntry
  1364. Dim MimeStr
  1365. Dim MimeOutPutStr
  1366. MimeMapSet = 0 ' Assume Success
  1367. ' First, check the number of args
  1368. If ArgCount < 3 Then
  1369. WScript.Echo "Error: Wrong number of Args for the Set MIMEMAP command"
  1370. WScript.Quit (GENERAL_FAILURE)
  1371. End If
  1372. MimePath = "IIS://" & MachineName
  1373. If ObjectPath <> "" Then MimePath = MimePath & "/" & ObjectPath
  1374. ' Get the object that contains the mimemap
  1375. Set MimeMapObject = GetObject(MimePath)
  1376. If (Err.Number <> 0) Then
  1377. ReportError ()
  1378. WScript.Echo "Error trying to get the Object: " & ObjectPath
  1379. WScript.Quit (Err.Number)
  1380. End If
  1381. ' Create a new MimeMapList of Mime Entries
  1382. ReDim MimeMapList(ArgCount - 3)
  1383. MimeOutPutStr = "MimeMap : (MimeMapList) "
  1384. ' Fill the list with mime entries
  1385. For MimeEntryIndex = 0 To UBound(MimeMapList)
  1386. MimeStr = Args(2 + MimeEntryIndex)
  1387. MimeOutPutStr = MimeOutPutStr & """" & MimeStr & """ "
  1388. Set MimeEntry = CreateObject("MimeMap")
  1389. MimeEntry.MimeType = Right (MimeStr, Len(MimeStr) - InStr(MimeStr, ","))
  1390. MimeEntry.Extension = Left(MimeStr, InStr(MimeStr, ",") - 1)
  1391. Set MimeMapList(MimeEntryIndex) = MimeEntry
  1392. Next
  1393. If (Err.Number <> 0) Then
  1394. ReportError ()
  1395. WScript.Echo "Error trying to Create the Mime Map List."
  1396. WScript.Quit (Err.Number)
  1397. End If
  1398. MimeMapObject.MimeMap = MimeMapList
  1399. MimeMapObject.Setinfo
  1400. If (Err.Number <> 0) Then
  1401. ReportError ()
  1402. WScript.Echo "Error Trying to set the Object's ""MimeMap"" property to the new mimemap list."
  1403. WScript.Quit (Err.Number)
  1404. End If
  1405. WScript.Echo MimeOutPutStr
  1406. End Function
  1407. ''''''''''''''''''''''''''
  1408. '
  1409. ' IsSpecialGetProperty
  1410. '
  1411. ' Checks to see if the property requires special processing in order to
  1412. ' display its contents.
  1413. '
  1414. ''''''''''''''''''''''''''
  1415. Function IsSpecialGetProperty(ObjectParameter)
  1416. On Error Resume Next
  1417. Select Case UCase(ObjectParameter)
  1418. Case "MIMEMAP"
  1419. IsSpecialGetProperty = True
  1420. Case Else
  1421. IsSpecialGetProperty = False
  1422. End Select
  1423. End Function
  1424. ''''''''''''''''''''''''''
  1425. '
  1426. ' DoSpecialGetProp
  1427. '
  1428. ' Checks to see if the property requires special processing in order to
  1429. ' display its contents.
  1430. '
  1431. ''''''''''''''''''''''''''
  1432. Function DoSpecialGetProp(ObjectPath, ObjectParameter, MachineName)
  1433. On Error Resume Next
  1434. Select Case UCase(ObjectParameter)
  1435. Case "MIMEMAP"
  1436. DoSpecialGetProp = MimeMapGet(ObjectPath, MachineName)
  1437. Case Else
  1438. DoSpecialGetProp = False
  1439. End Select
  1440. End Function
  1441. ''''''''''''''''''''''''''
  1442. '
  1443. ' IsSpecialSetProperty
  1444. '
  1445. ' Checks to see if the property is a type that needs to be handled
  1446. ' specially for compatibility with mdutil
  1447. '
  1448. ''''''''''''''''''''''''''
  1449. Function IsSpecialSetProperty(ObjectParameter)
  1450. On Error Resume Next
  1451. Select Case UCase(ObjectParameter)
  1452. Case "APPPOOLCOMMAND"
  1453. IsSpecialSetProperty = True
  1454. Case "SERVERCOMMAND"
  1455. IsSpecialSetProperty = True
  1456. Case "ACCESSPERM"
  1457. IsSpecialSetProperty = True
  1458. Case "VRPATH"
  1459. IsSpecialSetProperty = True
  1460. Case "AUTHORIZATION"
  1461. IsSpecialSetProperty = True
  1462. Case "MIMEMAP"
  1463. IsSpecialSetProperty = True
  1464. Case Else
  1465. IsSpecialSetProperty = False
  1466. End Select
  1467. End Function
  1468. ''''''''''''''''''''''''''
  1469. '
  1470. ' DoSpecialSetProp
  1471. '
  1472. ' Handles datatypes that need to be handled
  1473. ' specially for compatibility with mdutil
  1474. '
  1475. ''''''''''''''''''''''''''
  1476. Function DoSpecialSetProp(ObjectPath, ObjectParameter, MachineName)
  1477. Dim IIsObjectPath
  1478. Dim IIsObject
  1479. Dim ValueList
  1480. Dim ValueDisplay
  1481. Dim PermIndex
  1482. On Error Resume Next
  1483. DoSpecialSetProp = 0 ' Assume Success
  1484. Select Case UCase(ObjectParameter)
  1485. Case "SERVERCOMMAND"
  1486. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1487. Set IIsObject = GetObject(IIsObjectPath)
  1488. If (Err.Number <> 0) Then
  1489. ReportError ()
  1490. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  1491. WScript.Quit (Err.Number)
  1492. End If
  1493. If (IIsObject.KeyType <> "IIsWebServer") Then
  1494. ReportError ()
  1495. WScript.Echo "Can't set ServerCommand on a non-IIsWebServer object."
  1496. WScript.Quit (GENERAL_FAILURE)
  1497. End If
  1498. ValueList = CLng(Args(2))
  1499. Select Case ValueList
  1500. Case 1
  1501. IIsObject.Start
  1502. If (Err.Number <> 0) Then
  1503. ReportError ()
  1504. WScript.Echo "Error Trying To Start the server: " & ObjectPath
  1505. WScript.Quit (Err.Number)
  1506. End If
  1507. WScript.Echo "Server " & ObjectPath & " Successfully STARTED"
  1508. Case 2
  1509. IIsObject.Stop
  1510. If (Err.Number <> 0) Then
  1511. ReportError ()
  1512. WScript.Echo "Error Trying To Stop the server: " & ObjectPath
  1513. WScript.Quit (Err.Number)
  1514. End If
  1515. WScript.Echo "Server " & ObjectPath & " Successfully STOPPED"
  1516. Case 3
  1517. IIsObject.Pause
  1518. If (Err.Number <> 0) Then
  1519. ReportError ()
  1520. WScript.Echo "Error Trying To Pause the server: " & ObjectPath
  1521. WScript.Quit (Err.Number)
  1522. End If
  1523. WScript.Echo "Server " & ObjectPath & " Successfully PAUSED"
  1524. Case 4
  1525. IIsObject.Continue
  1526. If (Err.Number <> 0) Then
  1527. ReportError ()
  1528. WScript.Echo "Error Trying To Continue the server: " & ObjectPath
  1529. WScript.Quit (Err.Number)
  1530. End If
  1531. WScript.Echo "Server " & ObjectPath & " Successfully Continued"
  1532. Case Else
  1533. WScript.Echo "Invalid ServerCommand: " & ValueList
  1534. DoSpecialSetProp = GENERAL_FAILURE
  1535. End Select
  1536. Exit Function
  1537. Case "APPPOOLCOMMAND"
  1538. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1539. Set IIsObject = GetObject(IIsObjectPath)
  1540. If (Err.Number <> 0) Then
  1541. ReportError ()
  1542. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  1543. WScript.Quit (Err.Number)
  1544. End If
  1545. If (IIsObject.KeyType <> "IIsApplicationPool") Then
  1546. ReportError ()
  1547. WScript.Echo "Can't set AppPoolCommand on a non-IIsApplicationPool object."
  1548. WScript.Quit (GENERAL_FAILURE)
  1549. End If
  1550. ValueList = CLng(Args(2))
  1551. Select Case ValueList
  1552. Case 1
  1553. IIsObject.Start
  1554. If (Err.Number <> 0) Then
  1555. ReportError ()
  1556. WScript.Echo "Error Trying To Start the application pool: " & ObjectPath
  1557. WScript.Quit (Err.Number)
  1558. End If
  1559. WScript.Echo "Application pool " & ObjectPath & " Successfully STARTED"
  1560. Case 2
  1561. IIsObject.Stop
  1562. If (Err.Number <> 0) Then
  1563. ReportError ()
  1564. WScript.Echo "Error Trying To Stop the application pool: " & ObjectPath
  1565. WScript.Quit (Err.Number)
  1566. End If
  1567. WScript.Echo "Application pool " & ObjectPath & " Successfully STOPPED"
  1568. Case Else
  1569. WScript.Echo "Invalid AppPoolCommand: " & ValueList
  1570. DoSpecialSetProp = GENERAL_FAILURE
  1571. End Select
  1572. Exit Function
  1573. Case "ACCESSPERM"
  1574. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1575. Set IIsObject = GetObject(IIsObjectPath)
  1576. If (Err.Number <> 0) Then
  1577. ReportError ()
  1578. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  1579. WScript.Quit (Err.Number)
  1580. End If
  1581. ' Set the access flags to None, first, and then add them back, as necessary
  1582. IIsObject.AccessFlags = 0
  1583. ' Set up the display output
  1584. ValueDisplay = "AccessFlags (AccessPerm)" & (Right(Spacer, SpacerSize - Len("AccessFlags (AccessPerm)")) & ": " & "(" & TypeName(IIsObject.AccessFlags) & ") ")
  1585. ' Attempt to convert parameter to number
  1586. Dim APValue
  1587. Dim TempValStr
  1588. TempValStr = Args(2)
  1589. ' Check for Hex
  1590. If (UCase(Left(Args(2), 2)) = "0X") Then
  1591. TempValStr = "&H" & Right(TempValStr, Len(TempValStr) - 2)
  1592. End If
  1593. APValue = CLng(TempValStr)
  1594. If (Err.Number = 0) Then
  1595. IIsObject.AccessFlags = APValue
  1596. ValueDisplay = ValueDisplay & " " & APValue & " (0x" & Hex(APValue) & ")"
  1597. Else
  1598. Err.Clear
  1599. For PermIndex = 2 To ArgCount - 1
  1600. Select Case UCase(Args(PermIndex))
  1601. Case "READ"
  1602. IIsObject.AccessRead = True
  1603. ValueDisplay = ValueDisplay & " Read"
  1604. Case "WRITE"
  1605. IIsObject.AccessWrite = True
  1606. ValueDisplay = ValueDisplay & " Write"
  1607. Case "EXECUTE"
  1608. IIsObject.AccessExecute = True
  1609. ValueDisplay = ValueDisplay & " Execute"
  1610. Case "SCRIPT"
  1611. IIsObject.AccessScript = True
  1612. ValueDisplay = ValueDisplay & " Script"
  1613. Case Else
  1614. WScript.Echo "Error: Setting not supported: " & Args(PermIndex)
  1615. WScript.Quit (GENERAL_FAILURE)
  1616. End Select
  1617. Next
  1618. End If
  1619. If (Err.Number <> 0) Then
  1620. ReportError ()
  1621. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1622. WScript.Quit (Err.Number)
  1623. End If
  1624. IIsObject.Setinfo
  1625. If (Err.Number <> 0) Then
  1626. ReportError ()
  1627. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1628. WScript.Quit (Err.Number)
  1629. End If
  1630. ' Send the current settings to the screen
  1631. WScript.Echo ValueDisplay
  1632. Case "VRPATH"
  1633. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1634. Set IIsObject = GetObject(IIsObjectPath)
  1635. If (Err.Number <> 0) Then
  1636. ReportError ()
  1637. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  1638. WScript.Quit (Err.Number)
  1639. End If
  1640. ' Set the access flags to None, first, and then add them back, as necessary
  1641. IIsObject.Path = Args(2)
  1642. If (Err.Number <> 0) Then
  1643. ReportError ()
  1644. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1645. WScript.Quit (Err.Number)
  1646. End If
  1647. ' Set up the display output
  1648. ValueDisplay = "Path (VRPath)" & (Right(Spacer, SpacerSize - Len("Path (VRPath)")) & ": " & "(" & TypeName(IIsObject.Path) & ") " & IIsObject.Path)
  1649. IIsObject.Setinfo
  1650. If (Err.Number <> 0) Then
  1651. ReportError ()
  1652. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1653. WScript.Quit (Err.Number)
  1654. End If
  1655. ' Send the current settings to the screen
  1656. WScript.Echo ValueDisplay
  1657. Case "AUTHORIZATION"
  1658. IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
  1659. Set IIsObject = GetObject(IIsObjectPath)
  1660. If (Err.Number <> 0) Then
  1661. ReportError ()
  1662. WScript.Echo "Error Trying To Get the Object: " & ObjectPath
  1663. WScript.Quit (Err.Number)
  1664. End If
  1665. ' Set the auth flags to None, first, and then add them back, as necessary
  1666. IIsObject.AuthFlags = 0
  1667. ' Set up the display output
  1668. ValueDisplay = "Authorization" & (Right(Spacer, SpacerSize - Len("Authorization")) & ": " & "(" & TypeName(IIsObject.AuthFlags) & ") ")
  1669. For PermIndex = 2 To ArgCount - 1
  1670. Select Case UCase(Args(PermIndex))
  1671. Case "NT"
  1672. IIsObject.AuthNTLM = True
  1673. ValueDisplay = ValueDisplay & " NT"
  1674. Case "ANONYMOUS"
  1675. IIsObject.AuthAnonymous = True
  1676. ValueDisplay = ValueDisplay & " Anonymous"
  1677. Case "BASIC"
  1678. IIsObject.AuthBasic = True
  1679. ValueDisplay = ValueDisplay & " Basic"
  1680. Case Else
  1681. WScript.Echo "Error: Setting not supported: " & Args(PermIndex)
  1682. WScript.Quit (GENERAL_FAILURE)
  1683. End Select
  1684. Next
  1685. If (Err.Number <> 0) Then
  1686. ReportError ()
  1687. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1688. WScript.Quit (Err.Number)
  1689. End If
  1690. IIsObject.Setinfo
  1691. If (Err.Number <> 0) Then
  1692. ReportError ()
  1693. WScript.Echo "Error Trying To Set data on the Object: " & ObjectPath
  1694. WScript.Quit (Err.Number)
  1695. End If
  1696. ' Send the current settings to the screen
  1697. WScript.Echo ValueDisplay
  1698. Case "MIMEMAP"
  1699. DoSpecialSetProp = MimeMapSet(ObjectPath, ObjectParameter, MachineName)
  1700. ' Case "FILTER"
  1701. ' DoSpecialSetProp = FiltersSet()
  1702. Case Else
  1703. DoSpecialSetProp = GENERAL_FAILURE
  1704. End Select
  1705. End Function
  1706. ''''''''''''''''''''''''''''''
  1707. '
  1708. ' Function SeparateMachineName
  1709. '
  1710. ' This function will get the machine name from the Path parameter
  1711. ' that was passed into the script. It will also alter the passed in
  1712. ' path so that it contains only the rest of the path - not the machine
  1713. ' name. If there is no machine name in the path, then the script
  1714. ' will assume LocalHost.
  1715. '
  1716. ''''''''''''''''''''''''''''''
  1717. Function SeparateMachineName(Path)
  1718. On Error Resume Next
  1719. ' Temporarily, just return LocalHost
  1720. ' SeparateMachineName = "LocalHost"
  1721. SeparateMachineName = TargetServer
  1722. Exit Function
  1723. End Function
  1724. ''''''''''''''''''''''''''''''
  1725. '
  1726. ' Function MapSpecGetParamName
  1727. '
  1728. ' Some parameters in MDUTIL are named differently in ADSI.
  1729. ' This function maps the improtant parameter names to ADSI
  1730. ' names.
  1731. '
  1732. ''''''''''''''''''''''''''''''
  1733. Function MapSpecGetParamName(ObjectParameter)
  1734. On Error Resume Next
  1735. Select Case UCase(ObjectParameter)
  1736. Case "ACCESSPERM"
  1737. WScript.Echo "Note: Your parameter """ & ObjectParameter & """ is being mapped to AccessFlags"
  1738. WScript.Echo " Check individual perms using ""GET AccessRead"", ""GET AccessWrite"", etc."
  1739. MapSpecGetParamName = "AccessFlags"
  1740. Case "VRPATH"
  1741. 'WScript.Echo "Note: Your parameter """ & ObjectParameter & """ is being mapped to PATH"
  1742. MapSpecGetParamName = "Path"
  1743. Case "AUTHORIZATION"
  1744. WScript.Echo "Note: Your parameter """ & ObjectParameter & """ is being mapped to AuthFlags"
  1745. WScript.Echo " Check individual auths using ""GET AuthNTLM"", ""GET AuthBasic"", etc."
  1746. MapSpecGetParamName = "AuthFlags"
  1747. Case Else
  1748. ' Do nothing - the parameter doesn't map to anything special
  1749. MapSpecGetParamName = ObjectParameter
  1750. End Select
  1751. End Function
  1752. Sub ReportError()
  1753. ' On Error Resume Next
  1754. Dim ErrorDescription
  1755. Select Case (Err.Number)
  1756. Case &H80070003
  1757. ErrorDescription = "The path requested could not be found."
  1758. Case &H80070005
  1759. ErrorDescription = "Access is denied for the requested path or property."
  1760. Case &H80070094
  1761. ErrorDescription = "The requested path is being used by another application."
  1762. Case Else
  1763. ErrorDescription = Err.Description
  1764. End Select
  1765. WScript.Echo ErrorDescription
  1766. WScript.Echo "ErrNumber: " & Err.Number & " (0x" & Hex(Err.Number) & ")"
  1767. End Sub
  1768. Function SplitParam(ObjectPath)
  1769. ' Note: Assume the string has been sanitized (no leading or trailing slashes)
  1770. On Error Resume Next
  1771. Dim SlashIndex
  1772. Dim TempParam
  1773. Dim ObjectPathLen
  1774. SplitParam = "" ' Assume no parameter
  1775. ObjectPathLen = Len(ObjectPath)
  1776. ' Separate the path of the node from the parameter
  1777. SlashIndex = InStrRev(ObjectPath, "/")
  1778. If (SlashIndex = 0) Or (SlashIndex = ObjectPathLen) Then
  1779. TempParam = ObjectPath
  1780. ObjectPath = "" ' ObjectParameter is more important
  1781. Else
  1782. TempParam = ObjectPath
  1783. ObjectPath = Left(ObjectPath, SlashIndex - 1)
  1784. TempParam = Right(TempParam, Len(TempParam) - SlashIndex)
  1785. End If
  1786. SplitParam = TempParam
  1787. If (Err.Number <> 0) Then
  1788. ReportError ()
  1789. WScript.Echo "Error trying to Split the parameter from the object: " & ObjectPath
  1790. WScript.Quit (Err.Number)
  1791. End If
  1792. End Function
  1793. Function SplitLeftPath(ObjectPath)
  1794. ' Note: Assume the string has been sanitized (no leading or trailing slashes)
  1795. On Error Resume Next
  1796. Dim SlashIndex
  1797. Dim TmpLeftPath
  1798. Dim ObjectPathLen
  1799. 'WScript.Echo "SplitLeftPath: ObjectPath: " & ObjectPath
  1800. 'WScript.Echo "LastError: " & Err.Number & " (" & Hex (Err.Number) & ")"
  1801. SplitLeftPath = "" ' Assume no LeftPath
  1802. ObjectPathLen = Len(ObjectPath)
  1803. ' Separate the left part of the path from the remaining path
  1804. SlashIndex = InStr(ObjectPath, "/")
  1805. If (SlashIndex = 0) Or (SlashIndex = ObjectPathLen) Then
  1806. TmpLeftPath = ObjectPath
  1807. ObjectPath = ""
  1808. Else
  1809. TmpLeftPath = Left(ObjectPath, SlashIndex - 1)
  1810. ObjectPath = Right(ObjectPath, Len(ObjectPath) - SlashIndex)
  1811. End If
  1812. 'WScript.Echo "SplitLeftPath: ObjectPath: " & ObjectPath
  1813. 'WScript.Echo "SplitLeftPath: TmpLeftPath: " & TmpLeftPath
  1814. 'WScript.Echo "LastError: " & Err.Number & " (" & Hex (Err.Number) & ")"
  1815. SplitLeftPath = TmpLeftPath
  1816. 'WScript.Echo "SplitLeftPath: ObjectPath: " & ObjectPath
  1817. 'WScript.Echo "LastError: " & Err.Number & " (" & Hex (Err.Number) & ")"
  1818. 'WScript.Echo "SplitLeftPath: TmpLeftPath: " & TmpLeftPath
  1819. If (Err.Number <> 0) Then
  1820. ReportError ()
  1821. WScript.Echo "Error trying to split the left part of the path: " & ObjectPath
  1822. WScript.Quit (Err.Number)
  1823. End If
  1824. End Function
  1825. Sub SanitizePath(ObjectPath)
  1826. On Error Resume Next
  1827. ' Remove WhiteSpace
  1828. Do While (Left(ObjectPath, 1) = " ")
  1829. ObjectPath = Right(ObjectPath, Len(ObjectPath) - 1)
  1830. Loop
  1831. Do While (Right(ObjectPath, 1) = " ")
  1832. ObjectPath = Left(ObjectPath, Len(ObjectPath) - 1)
  1833. Loop
  1834. ' Replace all occurrences of \ with /
  1835. ObjectPath = Replace(ObjectPath, "\", "/")
  1836. ' Remove leading and trailing slashes
  1837. If Left(ObjectPath, 1) = "/" Then
  1838. ObjectPath = Right(ObjectPath, Len(ObjectPath) - 1)
  1839. End If
  1840. If Right(ObjectPath, 1) = "/" Then
  1841. ObjectPath = Left(ObjectPath, Len(ObjectPath) - 1)
  1842. End If
  1843. If (Err.Number <> 0) Then
  1844. ReportError ()
  1845. WScript.Echo "Error Trying To Sanitize the path: " & ObjectPath
  1846. WScript.Quit (Err.Number)
  1847. End If
  1848. End Sub
  1849. '''''''''''''''''''''''''''''
  1850. ' AppCreateCommand
  1851. '''''''''''''''''''''''''''''
  1852. Function AppCreateCommand(InProcFlag)
  1853. On Error Resume Next
  1854. Dim IIsObject
  1855. Dim IIsObjectPath
  1856. Dim ObjectPath
  1857. Dim MachineName
  1858. AppCreateCommand = 0 ' Assume Success
  1859. If ArgCount <> 2 Then
  1860. WScript.Echo "Error: Wrong number of Args for the APPCREATE command"
  1861. WScript.Quit (GENERAL_FAILURE)
  1862. End If
  1863. ObjectPath = Args(1)
  1864. SanitizePath ObjectPath
  1865. MachineName = SeparateMachineName(ObjectPath)
  1866. IIsObjectPath = "IIS://" & MachineName
  1867. If ObjectPath <> "" Then
  1868. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  1869. End If
  1870. Set IIsObject = GetObject(IIsObjectPath)
  1871. If (Err.Number <> 0) Then
  1872. ReportError ()
  1873. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  1874. WScript.Quit (Err.Number)
  1875. End If
  1876. IIsObject.AppCreate2 (InProcFlag)
  1877. If (Err.Number <> 0) Then
  1878. ReportError ()
  1879. WScript.Echo "Error trying to create the application: " & ObjectPath
  1880. WScript.Quit (Err.Number)
  1881. End If
  1882. WScript.Echo "Application Created."
  1883. End Function
  1884. '''''''''''''''''''''''''''''
  1885. ' AppDeleteCommand
  1886. '''''''''''''''''''''''''''''
  1887. Function AppDeleteCommand()
  1888. On Error Resume Next
  1889. Dim IIsObject
  1890. Dim IIsObjectPath
  1891. Dim ObjectPath
  1892. Dim MachineName
  1893. AppDeleteCommand = 0 ' Assume Success
  1894. If ArgCount <> 2 Then
  1895. WScript.Echo "Error: Wrong number of Args for the APPDELETE command"
  1896. WScript.Quit (GENERAL_FAILURE)
  1897. End If
  1898. ObjectPath = Args(1)
  1899. SanitizePath ObjectPath
  1900. MachineName = SeparateMachineName(ObjectPath)
  1901. IIsObjectPath = "IIS://" & MachineName
  1902. If ObjectPath <> "" Then
  1903. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  1904. End If
  1905. Set IIsObject = GetObject(IIsObjectPath)
  1906. If (Err.Number <> 0) Then
  1907. ReportError ()
  1908. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  1909. WScript.Quit (Err.Number)
  1910. End If
  1911. IIsObject.AppDelete
  1912. If (Err.Number <> 0) Then
  1913. ReportError ()
  1914. WScript.Echo "Error trying to DELETE the application: " & ObjectPath
  1915. WScript.Quit (Err.Number)
  1916. End If
  1917. WScript.Echo "Application Deleted."
  1918. End Function
  1919. '''''''''''''''''''''''''''''
  1920. ' AppUnloadCommand
  1921. '''''''''''''''''''''''''''''
  1922. Function AppUnloadCommand()
  1923. On Error Resume Next
  1924. Dim IIsObject
  1925. Dim IIsObjectPath
  1926. Dim ObjectPath
  1927. Dim MachineName
  1928. AppUnloadCommand = 0 ' Assume Success
  1929. If ArgCount <> 2 Then
  1930. WScript.Echo "Error: Wrong number of Args for the APPUNLOAD command"
  1931. WScript.Quit (GENERAL_FAILURE)
  1932. End If
  1933. ObjectPath = Args(1)
  1934. SanitizePath ObjectPath
  1935. MachineName = SeparateMachineName(ObjectPath)
  1936. IIsObjectPath = "IIS://" & MachineName
  1937. If ObjectPath <> "" Then
  1938. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  1939. End If
  1940. Set IIsObject = GetObject(IIsObjectPath)
  1941. If (Err.Number <> 0) Then
  1942. ReportError ()
  1943. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  1944. WScript.Quit (Err.Number)
  1945. End If
  1946. IIsObject.AppUnload
  1947. If (Err.Number <> 0) Then
  1948. ReportError ()
  1949. WScript.Echo "Error trying to UNLOAD the application: " & ObjectPath
  1950. WScript.Quit (Err.Number)
  1951. End If
  1952. WScript.Echo "Application Unloaded."
  1953. End Function
  1954. Function AppDisableCommand()
  1955. On Error Resume Next
  1956. Dim IIsObject
  1957. Dim IIsObjectPath
  1958. Dim ObjectPath
  1959. Dim MachineName
  1960. AppDisableCommand = 0 ' Assume Success
  1961. If ArgCount <> 2 Then
  1962. WScript.Echo "Error: Wrong number of Args for the APPDISABLE command"
  1963. WScript.Quit (GENERAL_FAILURE)
  1964. End If
  1965. ObjectPath = Args(1)
  1966. SanitizePath ObjectPath
  1967. MachineName = SeparateMachineName(ObjectPath)
  1968. 'debug
  1969. 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
  1970. IIsObjectPath = "IIS://" & MachineName
  1971. If ObjectPath <> "" Then
  1972. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  1973. End If
  1974. Set IIsObject = GetObject(IIsObjectPath)
  1975. If (Err.Number <> 0) Then
  1976. ReportError ()
  1977. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  1978. WScript.Quit (Err.Number)
  1979. End If
  1980. IIsObject.AppDisable
  1981. If (Err.Number <> 0) Then
  1982. ReportError ()
  1983. WScript.Echo "Error trying to disable the application: " & ObjectPath
  1984. WScript.Quit (Err.Number)
  1985. End If
  1986. 'debug
  1987. 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
  1988. WScript.Echo "Application Disabled."
  1989. End Function
  1990. Function AppEnableCommand()
  1991. On Error Resume Next
  1992. Dim IIsObject
  1993. Dim IIsObjectPath
  1994. Dim ObjectPath
  1995. Dim MachineName
  1996. AppEnableCommand = 0 ' Assume Success
  1997. If ArgCount <> 2 Then
  1998. WScript.Echo "Error: Wrong number of Args for the APPENABLE command"
  1999. WScript.Quit (GENERAL_FAILURE)
  2000. End If
  2001. ObjectPath = Args(1)
  2002. SanitizePath ObjectPath
  2003. MachineName = SeparateMachineName(ObjectPath)
  2004. 'debug
  2005. 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
  2006. IIsObjectPath = "IIS://" & MachineName
  2007. If ObjectPath <> "" Then
  2008. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  2009. End If
  2010. Set IIsObject = GetObject(IIsObjectPath)
  2011. If (Err.Number <> 0) Then
  2012. ReportError ()
  2013. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  2014. WScript.Quit (Err.Number)
  2015. End If
  2016. IIsObject.AppEnable
  2017. If (Err.Number <> 0) Then
  2018. ReportError ()
  2019. WScript.Echo "Error trying to Enable the application: " & ObjectPath
  2020. WScript.Quit (Err.Number)
  2021. End If
  2022. 'debug
  2023. 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
  2024. WScript.Echo "Application Enabled."
  2025. End Function
  2026. '''''''''''''''''''''''''''''
  2027. ' AppGetStatusCommand
  2028. '''''''''''''''''''''''''''''
  2029. Function AppGetStatusCommand()
  2030. On Error Resume Next
  2031. Dim IIsObject
  2032. Dim IIsObjectPath
  2033. Dim ObjectPath
  2034. Dim MachineName
  2035. Dim Status
  2036. AppGetStatusCommand = 0 ' Assume Success
  2037. If ArgCount <> 2 Then
  2038. WScript.Echo "Error: Wrong number of Args for the APPGETSTATUS command"
  2039. WScript.Quit (GENERAL_FAILURE)
  2040. End If
  2041. ObjectPath = Args(1)
  2042. SanitizePath ObjectPath
  2043. MachineName = SeparateMachineName(ObjectPath)
  2044. IIsObjectPath = "IIS://" & MachineName
  2045. If ObjectPath <> "" Then
  2046. IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  2047. End If
  2048. Set IIsObject = GetObject(IIsObjectPath)
  2049. If (Err.Number <> 0) Then
  2050. ReportError ()
  2051. WScript.Echo "Error trying to get the path of the application: " & ObjectPath
  2052. WScript.Quit (Err.Number)
  2053. End If
  2054. Status = IIsObject.AppGetStatus2
  2055. If (Err.Number <> 0) Then
  2056. ReportError ()
  2057. WScript.Echo "Error trying to retrieve the application STATUS: " & ObjectPath
  2058. WScript.Quit (Err.Number)
  2059. End If
  2060. WScript.Echo "Application Status: " & Status
  2061. End Function
  2062. ''''''''''''''''''''''''''
  2063. '
  2064. ' IsSecureProperty
  2065. '
  2066. ' Checks to see if the property requires special processing in order to
  2067. ' display its contents.
  2068. '
  2069. ''''''''''''''''''''''''''
  2070. Function IsSecureProperty(ObjectParameter,MachineName)
  2071. On Error Resume Next
  2072. Dim PropObj,Attribute
  2073. Set PropObj = GetObject("IIS://" & MachineName & "/schema/" & ObjectParameter)
  2074. If (Err.Number <> 0) Then
  2075. ReportError ()
  2076. WScript.Echo "Error trying to get the property: " & err.number
  2077. WScript.Quit (Err.Number)
  2078. End If
  2079. Attribute = PropObj.Secure
  2080. If (Attribute = True) Then
  2081. IsSecureProperty = True
  2082. Else
  2083. IsSecureProperty = False
  2084. End If
  2085. End Function