home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / adsutil.vbs < prev    next >
Text File  |  1997-10-16  |  66KB  |  2,316 lines

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