dolphindeploy 0.0.2-universal-dotnet

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/README.markdown +9 -0
  2. data/TODO +18 -0
  3. data/external/DolphinDeploy.IIS.IIS6.dll +0 -0
  4. data/external/Microsoft.Web.Administration.dll +0 -0
  5. data/external/TinySharpZip.dll +0 -0
  6. data/external/adsutil.vbs +2938 -0
  7. data/external/xunit/HTML.xslt +117 -0
  8. data/external/xunit/NUnitXml.xslt +121 -0
  9. data/external/xunit/xunit.console.exe +0 -0
  10. data/external/xunit/xunit.console.exe.config +21 -0
  11. data/external/xunit/xunit.console.x86.exe +0 -0
  12. data/external/xunit/xunit.console.x86.exe.config +21 -0
  13. data/external/xunit/xunit.dll +0 -0
  14. data/external/xunit/xunit.dll.tdnet +5 -0
  15. data/external/xunit/xunit.extensions.dll +0 -0
  16. data/external/xunit/xunit.extensions.xml +706 -0
  17. data/external/xunit/xunit.gui.exe +0 -0
  18. data/external/xunit/xunit.gui.x86.exe +0 -0
  19. data/external/xunit/xunit.installer.exe +0 -0
  20. data/external/xunit/xunit.runner.msbuild.dll +0 -0
  21. data/external/xunit/xunit.runner.tdnet.dll +0 -0
  22. data/external/xunit/xunit.runner.utility.dll +0 -0
  23. data/external/xunit/xunit.runner.utility.xml +1048 -0
  24. data/external/xunit/xunit.xml +2306 -0
  25. data/lib/IIS/IIS.rb +23 -0
  26. data/lib/IIS/IIS6.rb +165 -0
  27. data/lib/IIS/IIS7.rb +152 -0
  28. data/lib/IIS/IISVersion.rb +7 -0
  29. data/lib/configured_as/mvc_deployment.rb +174 -0
  30. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.5.1.ReSharper.user +45 -0
  31. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/AppPoolControllerTests.cs +39 -0
  32. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/DolphinDeploy.IIS.IIS6.Tests.csproj +69 -0
  33. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/DolphinDeploy.IIS.IIS6.Tests.csproj.user +6 -0
  34. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/Helper.cs +18 -0
  35. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/Properties/AssemblyInfo.cs +36 -0
  36. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/WebsiteControllerTests.cs +56 -0
  37. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.Tests.dll +0 -0
  38. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.Tests.pdb +0 -0
  39. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  40. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  41. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/test_site/index.htm +9 -0
  42. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/xunit.dll +0 -0
  43. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/bin/Debug/xunit.xml +2306 -0
  44. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  45. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.csproj.FileListAbsolute.txt +12 -0
  46. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.dll +0 -0
  47. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/DolphinDeploy.IIS.IIS6.Tests.pdb +0 -0
  48. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/obj/Debug/ResolveAssemblyReference.cache +0 -0
  49. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.Tests/test_site/index.htm +9 -0
  50. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.sln +26 -0
  51. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.suo +0 -0
  52. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/AppPoolController.cs +41 -0
  53. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6.csproj +56 -0
  54. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/IIS6Manager.cs +77 -0
  55. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/Properties/AssemblyInfo.cs +36 -0
  56. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/WebsiteController.cs +101 -0
  57. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/bin/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  58. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/bin/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  59. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  60. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.csproj.FileListAbsolute.txt +7 -0
  61. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.dll +0 -0
  62. data/lib/csharp/DolphinDeploy.IIS.IIS6/DolphinDeploy.IIS.IIS6/obj/Debug/DolphinDeploy.IIS.IIS6.pdb +0 -0
  63. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/BuildScriptCache/1/78fc7364.dat +0 -0
  64. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/ModuleIds.xml +4 -0
  65. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/NamedArguments/5/4b9722ad.dat +0 -0
  66. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/PdbInfo/61d4d5326252d9cd7476a391dfbbb2a47481ffa6 +0 -0
  67. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/ProjectModel/ProjectModel.dat +0 -0
  68. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/SymbolCache.bin +0 -0
  69. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/TodoCache/1/78fc7364.dat +0 -0
  70. data/lib/csharp/DolphinDeploy.IIS.IIS6/_ReSharper.DolphinDeploy.IIS.IIS6/WordIndex/1/72ab4678.dat +0 -0
  71. data/lib/deploycommandcreator.rb +34 -0
  72. data/lib/deploymentconfig.rb +15 -0
  73. data/lib/directory_cleanup.rb +16 -0
  74. data/lib/dolphindeploy.rb +12 -0
  75. data/lib/dolphindeploy_rake.rb +36 -0
  76. data/lib/file_manager.rb +30 -0
  77. data/lib/unzip.rb +11 -0
  78. data/spec/IIS/IIS6_spec.rb +24 -0
  79. data/spec/IIS/IIS_spec.rb +18 -0
  80. data/spec/configured_as/mvc_deployment_spec.rb +108 -0
  81. data/spec/deploycommandcreator_spec.rb +169 -0
  82. data/spec/deploymentconfig_spec.rb +202 -0
  83. data/spec/dolphindeploy_spec.rb +13 -0
  84. data/spec/file_manager_spec.rb +22 -0
  85. data/spec/support/spec_helper.rb +17 -0
  86. metadata +222 -0
data/README.markdown ADDED
@@ -0,0 +1,9 @@
1
+ # Welcome to the Dolphin Deploy project.
2
+
3
+ Dolphin Deploy provides an approach for deploying .NET based systems.
4
+
5
+ ## Example
6
+ rake dolphin:deploy[env,server] # Dolphin Deployment
7
+ rake dolphin:deploy[local,localhost]
8
+
9
+ ***This is still a work in progress***... **Please** do not use against production systems. The time will come, just not yet.
data/TODO ADDED
@@ -0,0 +1,18 @@
1
+ - Introduce extension points
2
+
3
+ - Support
4
+ Before do
5
+ exec ''
6
+ end
7
+
8
+ After do
9
+ exec ''
10
+ end
11
+
12
+
13
+
14
+ - Setup ISAPI filters on IIS6
15
+ - Turn off ScriptMap on IIS6 for static folder
16
+ - Ability to create virtual directories
17
+ - Logging
18
+ - Rake task to include in project
Binary file
Binary file
@@ -0,0 +1,2938 @@
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
+ Const StrRes0 = "COPY is not yet supported. It will be soon."
18
+ Const StrRes1 = "Command not recognized: "
19
+ Const StrRes2 = "For help, just type ""Cscript.exe adsutil.vbs""."
20
+ Const StrRes3 = "Usage:"
21
+ Const StrRes4 = " ADSUTIL.VBS <cmd> [<path> [<value>]]"
22
+ Const StrRes6 = "Description:"
23
+ Const StrRes7 = "IIS administration utility that enables the configuration of metabase properties."
24
+ Const StrRes9 = "Supported Commands:"
25
+ Const StrRes12 = "Samples:"
26
+ Const StrRes18 = "For Extended Help type:"
27
+ Const StrRes19 = " adsutil.vbs HELP"
28
+ Const StrRes21 = " ADSUTIL.VBS CMD [param param]"
29
+ Const StrRes23 = "Description:"
30
+ Const StrRes24 = "IIS administration utility that enables the manipulation with ADSI parameters"
31
+ Const StrRes26 = "Standard Commands:"
32
+ Const StrRes27 = " adsutil.vbs GET path - display chosen parameter"
33
+ Const StrRes28 = " adsutil.vbs SET path value ... - assign the new value"
34
+ Const StrRes29 = " adsutil.vbs ENUM path [""/P"" ] - enumerate all parameters for given path"
35
+ Const StrRes30 = " adsutil.vbs DELETE path - delete given path or parameter"
36
+ Const StrRes31 = " adsutil.vbs CREATE path [KeyType] - create given path and assigns it the given KeyType"
37
+ Const StrRes32 = " adsutil.vbs APPCREATEINPROC w3svc/1/root - Create an in-proc application"
38
+ Const StrRes33 = " adsutil.vbs APPCREATEOUTPROC w3svc/1/root - Create an out-proc application"
39
+ Const StrRes34 = " adsutil.vbs APPCREATEPOOLPROC w3svc/1/root- Create a pooled-proc application"
40
+ Const StrRes35 = " adsutil.vbs APPDELETE w3svc/1/root - Delete the application if there is one"
41
+ Const StrRes36 = " adsutil.vbs APPUNLOAD w3svc/1/root - Unload an application from w3svc runtime lookup table."
42
+ Const StrRes37 = " adsutil.vbs APPDISABLE w3svc/1/root - Disable an application - appropriate for porting to another machine."
43
+ Const StrRes38 = " adsutil.vbs APPENABLE w3svc/1/root - Enable an application - appropriate for importing from another machine."
44
+ Const StrRes39 = " adsutil.vbs APPGETSTATUS w3svc/1/root - Get status of the application"
45
+ Const StrRes40 = "New ADSI Options:"
46
+ Const StrRes41 = " /P - Valid for ENUM only. Enumerates the paths only (no data)"
47
+ Const StrRes42 = " KeyType - Valide for CREATE only. Assigns the valid KeyType to the path"
48
+ Const StrRes43 = "Extended ADSUTIL Commands:"
49
+ Const StrRes44 = " adsutil.vbs FIND path - find the paths where a given parameter is set"
50
+ Const StrRes45 = " adsutil.vbs CREATE_VDIR path - create given path as a Virtual Directory"
51
+ Const StrRes46 = " adsutil.vbs CREATE_VSERV path - create given path as a Virtual Server"
52
+ Const StrRes47 = " adsutil.vbs START_SERVER path - starts the given web site"
53
+ Const StrRes48 = " adsutil.vbs STOP_SERVER path - stops the given web site"
54
+ Const StrRes49 = " adsutil.vbs PAUSE_SERVER path - pauses the given web site"
55
+ Const StrRes50 = " adsutil.vbs CONTINUE_SERVER path - continues the given web site"
56
+ Const StrRes52 = " adsutil.vbs GET W3SVC/1/ServerBindings"
57
+ Const StrRes53 = " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
58
+ Const StrRes54 = " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
59
+ Const StrRes55 = " adsutil.vbs START_SERVER W3SVC/1"
60
+ Const StrRes56 = " adsutil.vbs ENUM /P W3SVC"
61
+ Const StrRes57 = "Extended ADSUTIL Commands:"
62
+ Const StrRes58 = " adsutil.vbs FIND path - find the paths where a given parameter is set"
63
+ Const StrRes59 = " adsutil.vbs CREATE_VDIR path - create given path as a Virtual Directory"
64
+ Const StrRes60 = " adsutil.vbs CREATE_VSERV path - create given path as a Virtual Server"
65
+ Const StrRes61 = " adsutil.vbs START_SERVER path - starts the given web site"
66
+ Const StrRes62 = " adsutil.vbs STOP_SERVER path - stops the given web site"
67
+ Const StrRes63 = " adsutil.vbs PAUSE_SERVER path - pauses the given web site"
68
+ Const StrRes64 = " adsutil.vbs CONTINUE_SERVER path - continues the given web site"
69
+ Const StrRes65 = "Samples:"
70
+ Const StrRes66 = " adsutil.vbs GET W3SVC/1/ServerBindings"
71
+ Const StrRes67 = " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
72
+ Const StrRes68 = " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
73
+ Const StrRes69 = " adsutil.vbs START_SERVER W3SVC/1"
74
+ Const StrRes70 = " adsutil.vbs ENUM /P W3SVC"
75
+ Const StrRes71 = "This script does not work with WScript."
76
+ Const StrRes72 = "To run this script using CScript, type: ""CScript.exe "
77
+ Const StrRes73 = "Error Trying to write the registry settings!"
78
+ Const StrRes74 = "Successfully registered CScript"
79
+ Const StrRes75 = "To run this script type: ""CScript.Exe adsutil.vbs <cmd> <params>"""
80
+ Const StrRes76 = "Error: Wrong number of Args for the SET command"
81
+ Const StrRes77 = "Error Trying To Get the Object: "
82
+ Const StrRes78 = "Error Trying To GET the Schema of the property: "
83
+ Const StrRes79 = "Error: Unknown data type in schema: "
84
+ Const StrRes80 = "Error Trying To SET the Property: "
85
+ Const StrRes81 = "Error: Wrong number of Args for the GET command"
86
+ Const StrRes82 = "Error Trying To GET the Object (GetObject Failed): "
87
+ Const StrRes83 = "Error Trying To GET the Schema of the property: "
88
+ Const StrRes84 = "Error Trying To GET the property: (Get Method Failed) "
89
+ Const StrRes85 = " (This property is probably not allowed at this node)"
90
+ Const StrRes86 = "The parameter """
91
+ Const StrRes87 = " is not set at this node."
92
+ Const StrRes90 = " Items)"
93
+ Const StrRes91 = "Error Trying To GET the Property: "
94
+ Const StrRes92 = "Error: Invalid arguments for the ENUM command"
95
+ Const StrRes93 = "Error: Wrong number of Args for the ENUM command"
96
+ Const StrRes94 = "Error Trying To ENUM the Object (GetObject Failed): "
97
+ Const StrRes95 = "Error Trying To GET the Schema of the class: "
98
+ Const StrRes96 = "Error trying to get the list of properties: "
99
+ Const StrRes97 = "Warning: The optionalproperties list is of an invalid type"
100
+ Const StrRes98 = "Warning: The OptionalProperties list for this node is empty."
101
+ Const StrRes99 = "Error trying to enumerate the Optional properties (Couldn't Get Property Information): "
102
+ Const StrRes100 = "Last Property Name: "
103
+ Const StrRes102 = " Items)"
104
+ Const StrRes103 = "DataType: "
105
+ Const StrRes104 = " Not Yet Supported on property: "
106
+ Const StrRes105 = "Error trying to enumerate the Optional properties (Error trying to get property value): "
107
+ Const StrRes108 = "Continuing..."
108
+ Const StrRes109 = "Error trying to enumerate the properties lists:"
109
+ Const StrRes111 = "Error trying to enumerate the child nodes"
110
+ Const StrRes112 = "Error: Wrong number of Args for the CREATE command"
111
+ Const StrRes120 = "Error accessing the object: "
112
+ Const StrRes121 = "Error creating the object: "
113
+ Const StrRes123 = "WARNING: The parent path ("
114
+ Const StrRes124 = ") was not already created."
115
+ Const StrRes125 = " This means that some of the intermediate objects will not have an accurate"
116
+ Const StrRes126 = " Object Type. You should fix this by setting the KeyType on the intermediate"
117
+ Const StrRes127 = " objects."
118
+ Const StrRes128 = "WARNING: The Object Type of this object was not specified or was specified as"
119
+ Const StrRes129 = " IIsObject. This means that you will not be able to set or get properties"
120
+ Const StrRes130 = " on the object until the KeyType property is set."
121
+ Const StrRes131 = "created """
122
+ Const StrRes132 = "Error: Wrong number of Args for the DELETE command"
123
+ Const StrRes133 = "Error deleting the object: "
124
+ Const StrRes134 = "deleted property """
125
+ Const StrRes135 = "Error deleting the object: "
126
+ Const StrRes136 = "deleted path """
127
+ Const StrRes137 = "ENUM_ALL Command not yet supported"
128
+ Const StrRes138 = "Error: Wrong number of Args for the Copy/Move command"
129
+ Const StrRes139 = "Error trying to open the object: "
130
+ Const StrRes140 = "Error trying to Copy/Move Source to Dest."
131
+ Const StrRes141 = "copied from "
132
+ Const StrRes142 = " to "
133
+ Const StrRes143 = "moved from "
134
+ Const StrRes145 = "Error: Wrong number of Args for the START_SERVER command"
135
+ Const StrRes146 = "Error trying to open the object: "
136
+ Const StrRes147 = "Error trying to START the server: "
137
+ Const StrRes148 = "Server "
138
+ Const StrRes149 = " Successfully STARTED"
139
+ Const StrRes150 = "Error: Wrong number of Args for the STOP_SERVER command"
140
+ Const StrRes151 = "Error trying to open the object: "
141
+ Const StrRes152 = "Error trying to STOP the server: "
142
+ Const StrRes154 = " Successfully STOPPED"
143
+ Const StrRes155 = "Error: Wrong number of Args for the PAUSE_SERVER command"
144
+ Const StrRes156 = "Error trying to open the object: "
145
+ Const StrRes157 = "Error trying to PAUSE the server: "
146
+ Const StrRes159 = " Successfully PAUSED"
147
+ Const StrRes160 = "Error: Wrong number of Args for the CONTINUE_SERVER command"
148
+ Const StrRes161 = "Error trying to open the object: "
149
+ Const StrRes162 = "Error trying to CONTINUE the server: "
150
+ Const StrRes164 = " Successfully CONTINUED"
151
+ Const StrRes165 = "Error: Wrong number of Args for the FIND_DATA command"
152
+ Const StrRes166 = "Error trying to find data paths for the Object (GetObject Failed): "
153
+ Const StrRes167 = "Error trying to get a path list (GetDataPaths Failed): "
154
+ Const StrRes168 = "Property "
155
+ Const StrRes169 = " was not found at any node beneath "
156
+ Const StrRes171 = " found at:"
157
+ Const StrRes172 = "Error listing the data paths (_newEnum Failed): "
158
+ Const StrRes173 = "Error trying to get the Object: "
159
+ Const StrRes175 = "Error trying to Create the Mime Map List."
160
+ Const StrRes176 = "Error: Wrong number of Args for the Set MIMEMAP command"
161
+ Const StrRes177 = "Error trying to get the Object: "
162
+ Const StrRes179 = "Error Trying to set the Object's ""MimeMap"" property to the new mimemap list."
163
+ Const StrRes180 = "Error Trying To Get the Object: "
164
+ Const StrRes181 = "Can't set ServerCommand on a non-IIsWebServer object."
165
+ Const StrRes182 = "Error Trying To Start the server: "
166
+ Const StrRes184 = " Successfully STARTED"
167
+ Const StrRes185 = "Error Trying To Stop the server: "
168
+ Const StrRes187 = " Successfully STOPPED"
169
+ Const StrRes188 = "Error Trying To Pause the server: "
170
+ Const StrRes190 = " Successfully PAUSED"
171
+ Const StrRes191 = "Error Trying To Continue the server: "
172
+ Const StrRes193 = " Successfully Continued"
173
+ Const StrRes194 = "Invalid ServerCommand: "
174
+ Const StrRes195 = "Error Trying To Get the Object: "
175
+ Const StrRes196 = "Can't set AppPoolCommand on a non-IIsApplicationPool object."
176
+ Const StrRes197 = "Error Trying To Start the application pool: "
177
+ Const StrRes198 = "Application pool "
178
+ Const StrRes199 = " Successfully STARTED"
179
+ Const StrRes200 = "Error Trying To Stop the application pool: "
180
+ Const StrRes202 = " Successfully STOPPED"
181
+ Const StrRes203 = "Invalid AppPoolCommand: "
182
+ Const StrRes204 = "Error Trying To Get the Object: "
183
+ Const StrRes205 = "Error: Setting not supported: "
184
+ Const StrRes206 = "Error Trying To Set data on the Object: "
185
+ Const StrRes208 = "Error Trying To Get the Object: "
186
+ Const StrRes215 = "Note: Your parameter """
187
+ Const StrRes216 = " is being mapped to AccessFlags"
188
+ Const StrRes217 = " Check individual perms using ""GET AccessRead"", ""GET AccessWrite"", etc."
189
+ Const StrRes221 = " is being mapped to AuthFlags"
190
+ Const StrRes222 = " Check individual auths using ""GET AuthNTLM"", ""GET AuthBasic"", etc."
191
+ Const StrRes223 = "ErrNumber: "
192
+ Const StrRes225 = "Error trying to Split the parameter from the object: "
193
+ Const StrRes234 = "Error trying to split the left part of the path: "
194
+ Const StrRes235 = "Error Trying To Sanitize the path: "
195
+ Const StrRes236 = "Error: Wrong number of Args for the APPCREATE command"
196
+ Const StrRes237 = "Error trying to get the path of the application: "
197
+ Const StrRes238 = "Error trying to create the application: "
198
+ Const StrRes239 = "Application Created."
199
+ Const StrRes240 = "Error: Wrong number of Args for the APPDELETE command"
200
+ Const StrRes242 = "Error trying to DELETE the application: "
201
+ Const StrRes243 = "Application Deleted."
202
+ Const StrRes244 = "Error: Wrong number of Args for the APPUNLOAD command"
203
+ Const StrRes246 = "Error trying to UNLOAD the application: "
204
+ Const StrRes247 = "Application Unloaded."
205
+ Const StrRes248 = "Error: Wrong number of Args for the APPDISABLE command"
206
+ Const StrRes251 = "Error trying to disable the application: "
207
+ Const StrRes253 = "Application Disabled."
208
+ Const StrRes254 = "Error: Wrong number of Args for the APPENABLE command"
209
+ Const StrRes257 = "Error trying to Enable the application: "
210
+ Const StrRes259 = "Application Enabled."
211
+ Const StrRes260 = "Error: Wrong number of Args for the APPGETSTATUS command"
212
+ Const StrRes262 = "Error trying to retrieve the application STATUS: "
213
+ Const StrRes263 = "Application Status: "
214
+ Const StrRes264 = "Error trying to get the property: "
215
+ Const StrRes265 = "Would you like to register CScript as your default host for VBscript?"
216
+ Const StrRes266 = "Register CScript"
217
+ Const StrRes267 = "The path requested could not be found."
218
+ Const StrRes268 = "Access is denied for the requested path or property."
219
+ Const StrRes269 = "The requested path is being used by another application."
220
+ Const StrRes270 = "Authorization"
221
+ Const StrRes271 = " Anonymous"
222
+ Const StrRes272 = " Basic"
223
+
224
+ Dim fso
225
+ Set fso = CreateObject("Scripting.FileSystemObject")
226
+ Const vbSpace = " "
227
+
228
+ ' Get the overridden UI language.
229
+ Function GetLangID()
230
+ Dim args, lang
231
+
232
+ Set args = WScript.Arguments.Named
233
+ If args.Exists("lang") Then
234
+ lang = args.Item("lang")
235
+ GetLangID = CInt(lang)
236
+ Else
237
+ GetLangID = GetUILanguage()
238
+ End If
239
+
240
+ End Function
241
+
242
+ ' Get a localized resources for 'resourceID' if available;
243
+ ' otherwise, get the neutral resource.
244
+ Function GetLocalizedResource(resourceID)
245
+ Const ForReading = 1, TristateUseDefault = -2
246
+ Dim lang, value, ini
247
+
248
+ lang = GetLangID()
249
+ ini = fso.GetParentFolderName(WScript.ScriptFullName) & "\" _
250
+ & ToHex(lang) & "\" & fso.GetBaseName(WScript.ScriptName) & ".ini"
251
+
252
+ If fso.FileExists(ini) Then
253
+ Dim stream, file
254
+
255
+ Set file = fso.GetFile(ini)
256
+ Set stream = file.OpenAsTextStream(ForReading, TristateUseDefault)
257
+ value = ReadResource(stream, resourceID)
258
+ End If
259
+
260
+ If Not IsEmpty(value) Then
261
+ GetLocalizedResource = value
262
+ Else
263
+ GetLocalizedResource = Eval(resourceID)
264
+ End If
265
+ End Function
266
+
267
+ ' Read a resource ID from the TextStream
268
+ Function ReadResource(stream, resourceID)
269
+ Const ERROR_FILE_NOT_FOUND = 2
270
+ Dim ln, arr, key, value
271
+
272
+ If Not IsObject(stream) Then Err.Raise ERROR_FILE_NOT_FOUND
273
+
274
+ Do Until stream.AtEndOfStream
275
+ ln = stream.ReadLine
276
+
277
+ arr = Split(ln, "=", 2, 1)
278
+ If UBound(arr, 1) = 1 Then
279
+ ' Trim the key and the value first before trimming quotes
280
+ key = arr(0)
281
+ key = TrimSpace(key)
282
+ 'key = Replace(key, String(1, vbTab), "")
283
+
284
+ If StrComp(resourceID, key, 1) = 0 Then
285
+ value = TrimChar(TrimSpace(arr(1)), """")
286
+ ReadResource = value
287
+ Exit Do
288
+ End If
289
+ End If
290
+ Loop
291
+
292
+ stream.Close
293
+ End Function
294
+
295
+ Function TrimSpace(s)
296
+ Dim c
297
+ do
298
+ c = Left(s, 1)
299
+ if c <> vbTab and c <> vbSpace then
300
+ exit do
301
+ end if
302
+ s = Right(s, len(s) - 1)
303
+ loop
304
+
305
+ do
306
+ c = Right(s, 1)
307
+ if c <> vbTab and c <> vbSpace then
308
+ exit do
309
+ end if
310
+ s = Left(s, len(s) - 1)
311
+ loop
312
+
313
+ TrimSpace = s
314
+ End Function
315
+
316
+ ' Trim a character from the text string
317
+ Function TrimChar(s, c)
318
+ Dim a
319
+ do
320
+ a = Left(s, 1)
321
+ if a <> c then
322
+ exit do
323
+ end if
324
+ s = Right(s, len(s) - 1)
325
+ loop
326
+
327
+ do
328
+ a = Right(s, 1)
329
+ if a <> c then
330
+ exit do
331
+ end if
332
+ s = Left(s, len(s) - 1)
333
+ loop
334
+
335
+ TrimChar = s
336
+ End Function
337
+
338
+ Function ToHex(n)
339
+ Dim s : s = Hex(n)
340
+ ToHex = String(4 - Len(s), "0") & s
341
+ End Function
342
+
343
+ ''''''''''''''''''
344
+ ' Main Script Code
345
+ ''''''''''''''''''
346
+ Dim ArgObj ' Object which contains the command line argument
347
+ Dim Result ' Result of the command function call
348
+ Dim Args(999) ' Array that contains all of the non-global arguments
349
+ Dim ArgCount ' Tracks the size of the Args array
350
+
351
+ ' Used for string formatting
352
+ Dim Spacer
353
+ Dim SpacerSize
354
+
355
+ Const IIS_DATA_NO_INHERIT = 0
356
+ Const IIS_DATA_INHERIT = 1
357
+ Const GENERAL_FAILURE = 2
358
+ Const GENERAL_WARNING = 1
359
+ Const AppCreate_InProc = 0
360
+ Const AppCreate_OutOfProc = 1
361
+ Const AppCreate_PooledOutOfProc = 2
362
+
363
+ Const APPSTATUS_NOTDEFINED = 2
364
+ Const APPSTATUS_RUNNING = 1
365
+ Const APPSTATUS_STOPPED = 0
366
+
367
+ Spacer = " " ' Used to format the strings
368
+ SpacerSize = Len(Spacer)
369
+
370
+ ' Note: The default execution mode may be under WScript.exe.
371
+ ' That would be very annoying since WScript has popups for Echo.
372
+ ' So, I want to detect that, and warn the user that it may cause
373
+ ' problems.
374
+ DetectExeType
375
+
376
+ ' Get the Arguments object
377
+ Set ArgObj = WScript.Arguments
378
+
379
+ ' Test to make sure there is at least one command line arg - the command
380
+ If ArgObj.Count < 1 Then
381
+ DisplayHelpMessage
382
+ WScript.Quit (GENERAL_FAILURE)
383
+ End If
384
+
385
+ '*****************************************************
386
+ Dim TargetServer 'The server to be examined/modified
387
+ Dim I
388
+ For I = 0 To ArgObj.Count - 1
389
+ If LCase(Left(ArgObj.Item(I), 3)) = "-s:" Then
390
+ TargetServer = Right(ArgObj.Item(I), Len(ArgObj.Item(I)) - 3)
391
+ Else
392
+ Args(ArgCount) = ArgObj.Item(I)
393
+ ArgCount = ArgCount + 1
394
+ End If
395
+ Next
396
+ If Len(TargetServer) = 0 Then
397
+ TargetServer = "localhost"
398
+ End If
399
+ '*****************************************************
400
+
401
+ ' Call the function associated with the given command
402
+ Select Case UCase(Args(0))
403
+ Case "SET"
404
+ Result = SetCommand()
405
+ Case "CREATE"
406
+ Result = CreateCommand("")
407
+ Case "DELETE"
408
+ Result = DeleteCommand()
409
+ Case "GET"
410
+ Result = GetCommand()
411
+ Case "ENUM"
412
+ Result = EnumCommand(False, "")
413
+ Case "ENUM_ALL"
414
+ Result = EnumCommand(True, "")
415
+ Case "ENUMALL"
416
+ Result = EnumCommand(True, "")
417
+ Case "COPY"
418
+ Result = CopyMoveCommand(True) ' The TRUE means COPY, not MOVE
419
+ Case "MOVE"
420
+ Result = CopyMoveCommand(False) ' The FALSE means MOVE, not COPY
421
+ Case "CREATE_VDIR"
422
+ Result = CreateCommand("IIsWebVirtualDir")
423
+ Case "CREATE_VSERV"
424
+ Result = CreateCommand("IIsWebServer")
425
+ Case "START_SERVER"
426
+ Result = StartServerCommand()
427
+ Case "STOP_SERVER"
428
+ Result = StopServerCommand()
429
+ Case "PAUSE_SERVER"
430
+ Result = PauseServerCommand()
431
+ Case "CONTINUE_SERVER"
432
+ Result = ContinueServerCommand()
433
+ ' New Stuff being added
434
+ Case "FIND"
435
+ Result = FindData()
436
+ Case "COPY"
437
+ WScript.Echo GetLocalizedResource("StrRes0")
438
+ Case "APPCREATEINPROC"
439
+ Result = AppCreateCommand(AppCreate_InProc)
440
+ Case "APPCREATEOUTPROC"
441
+ Result = AppCreateCommand(AppCreate_OutOfProc)
442
+ Case "APPCREATEPOOLPROC"
443
+ Result = AppCreateCommand(AppCreate_PooledOutOfProc)
444
+ Case "APPDELETE"
445
+ Result = AppDeleteCommand()
446
+ Case "APPUNLOAD"
447
+ Result = AppUnloadCommand()
448
+ Case "APPDISABLE"
449
+ Result = AppDisableCommand()
450
+ Case "APPENABLE"
451
+ Result = AppEnableCommand()
452
+ Case "APPGETSTATUS"
453
+ Result = AppGetStatusCommand()
454
+ Case "HELP"
455
+ DisplayHelpMessageEx
456
+
457
+ ' End New Stuff
458
+
459
+ Case Else
460
+ WScript.Echo GetLocalizedResource("StrRes1") & Args(0)
461
+ WScript.Echo GetLocalizedResource("StrRes2")
462
+ Result = GENERAL_FAILURE
463
+
464
+ End Select
465
+
466
+ WScript.Quit (Result)
467
+
468
+ ''''''''''
469
+ ' End Main
470
+ ''''''''''
471
+
472
+
473
+ ''''''''''''''''''''''''''''
474
+ '
475
+ ' Display Help Message
476
+ '
477
+ ''''''''''''''''''''''''''''
478
+ Sub DisplayHelpMessage()
479
+ WScript.Echo
480
+ WScript.Echo GetLocalizedResource("StrRes3")
481
+ WScript.Echo GetLocalizedResource("StrRes4")
482
+ WScript.Echo
483
+ WScript.Echo GetLocalizedResource("StrRes6")
484
+ WScript.Echo GetLocalizedResource("StrRes7")
485
+ WScript.Echo
486
+ WScript.Echo GetLocalizedResource("StrRes9")
487
+ WScript.Echo " GET, SET, ENUM, DELETE, CREATE, COPY, "
488
+ WScript.Echo " APPCREATEINPROC, APPCREATEOUTPROC, APPCREATEPOOLPROC, APPDELETE, APPUNLOAD, APPGETSTATUS "
489
+ WScript.Echo
490
+ WScript.Echo GetLocalizedResource("StrRes12")
491
+ WScript.Echo " adsutil.vbs GET W3SVC/1/ServerBindings"
492
+ WScript.Echo " adsutil.vbs SET W3SVC/1/ServerBindings "":81:"""
493
+ WScript.Echo " adsutil.vbs CREATE W3SVC/1/Root/MyVdir ""IIsWebVirtualDir"""
494
+ WScript.Echo " adsutil.vbs START_SERVER W3SVC/1"
495
+ WScript.Echo " adsutil.vbs ENUM /P W3SVC"
496
+ WScript.Echo
497
+ WScript.Echo GetLocalizedResource("StrRes18")
498
+ WScript.Echo " adsutil.vbs HELP"
499
+ End Sub
500
+
501
+
502
+
503
+ ''''''''''''''''''''''''''''
504
+ '
505
+ ' Display Help Message
506
+ '
507
+ ''''''''''''''''''''''''''''
508
+ Sub DisplayHelpMessageEx()
509
+
510
+ WScript.Echo
511
+ WScript.Echo GetLocalizedResource("StrRes3")
512
+ WScript.Echo GetLocalizedResource("StrRes21")
513
+ WScript.Echo
514
+ WScript.Echo GetLocalizedResource("StrRes23")
515
+ WScript.Echo GetLocalizedResource("StrRes24")
516
+ WScript.Echo
517
+ WScript.Echo GetLocalizedResource("StrRes26")
518
+ WScript.Echo GetLocalizedResource("StrRes27")
519
+ WScript.Echo GetLocalizedResource("StrRes28")
520
+ WScript.Echo GetLocalizedResource("StrRes29")
521
+ WScript.Echo GetLocalizedResource("StrRes30")
522
+ WScript.Echo GetLocalizedResource("StrRes31")
523
+ WScript.Echo
524
+ WScript.Echo GetLocalizedResource("StrRes32")
525
+ WScript.Echo GetLocalizedResource("StrRes33")
526
+ WScript.Echo GetLocalizedResource("StrRes34")
527
+ WScript.Echo GetLocalizedResource("StrRes35")
528
+ WScript.Echo GetLocalizedResource("StrRes36")
529
+ WScript.Echo GetLocalizedResource("StrRes37")
530
+ WScript.Echo GetLocalizedResource("StrRes38")
531
+ WScript.Echo GetLocalizedResource("StrRes39")
532
+ WScript.Echo
533
+ WScript.Echo GetLocalizedResource("StrRes40")
534
+ WScript.Echo GetLocalizedResource("StrRes41")
535
+ WScript.Echo GetLocalizedResource("StrRes42")
536
+ WScript.Echo
537
+ WScript.Echo GetLocalizedResource("StrRes43")
538
+ WScript.Echo GetLocalizedResource("StrRes44")
539
+ WScript.Echo GetLocalizedResource("StrRes45")
540
+ WScript.Echo GetLocalizedResource("StrRes46")
541
+ WScript.Echo GetLocalizedResource("StrRes47")
542
+ WScript.Echo GetLocalizedResource("StrRes48")
543
+ WScript.Echo GetLocalizedResource("StrRes49")
544
+ WScript.Echo GetLocalizedResource("StrRes50")
545
+ WScript.Echo
546
+ WScript.Echo
547
+ WScript.Echo GetLocalizedResource("StrRes12")
548
+ WScript.Echo GetLocalizedResource("StrRes52")
549
+ WScript.Echo GetLocalizedResource("StrRes53")
550
+ WScript.Echo GetLocalizedResource("StrRes54")
551
+ WScript.Echo GetLocalizedResource("StrRes55")
552
+ WScript.Echo GetLocalizedResource("StrRes56")
553
+
554
+ WScript.Echo GetLocalizedResource("StrRes57")
555
+ WScript.Echo GetLocalizedResource("StrRes58")
556
+ WScript.Echo GetLocalizedResource("StrRes59")
557
+ WScript.Echo GetLocalizedResource("StrRes60")
558
+ WScript.Echo GetLocalizedResource("StrRes61")
559
+ WScript.Echo GetLocalizedResource("StrRes62")
560
+ WScript.Echo GetLocalizedResource("StrRes63")
561
+ WScript.Echo GetLocalizedResource("StrRes64")
562
+ WScript.Echo
563
+ WScript.Echo
564
+ WScript.Echo GetLocalizedResource("StrRes65")
565
+ WScript.Echo GetLocalizedResource("StrRes66")
566
+ WScript.Echo GetLocalizedResource("StrRes67")
567
+ WScript.Echo GetLocalizedResource("StrRes68")
568
+ WScript.Echo GetLocalizedResource("StrRes69")
569
+ WScript.Echo GetLocalizedResource("StrRes70")
570
+
571
+ ' adsutil.vbs ENUM_ALL path - recursively enumerate all parameters
572
+ ' adsutil.vbs COPY pathsrc pathdst - copy all from pathsrc to pathdst (will create pathdst)
573
+ ' adsutil.vbs SCRIPT scriptname - runs the script
574
+
575
+ ' -path has format: {computer}/{service}/{instance}/{URL}/{Parameter}
576
+
577
+ End Sub
578
+
579
+
580
+
581
+
582
+
583
+
584
+ '''''''''''''''''''''''''''
585
+ '
586
+ ' DetectExeType
587
+ '
588
+ ' This can detect the type of exe the
589
+ ' script is running under and warns the
590
+ ' user of the popups.
591
+ '
592
+ '''''''''''''''''''''''''''
593
+ Sub DetectExeType()
594
+ Dim ScriptHost
595
+ Dim ShellObject
596
+
597
+ Dim CurrentPathExt
598
+ Dim EnvObject
599
+
600
+ Dim RegCScript
601
+ Dim RegPopupType ' This is used to set the pop-up box flags.
602
+ ' I couldn't find the pre-defined names
603
+ RegPopupType = 32 + 4
604
+
605
+ On Error Resume Next
606
+
607
+ ScriptHost = WScript.FullName
608
+ ScriptHost = Right(ScriptHost, Len(ScriptHost) - InStrRev(ScriptHost, "\"))
609
+
610
+ If (UCase(ScriptHost) = "WSCRIPT.EXE") Then
611
+ WScript.Echo GetLocalizedResource("StrRes71")
612
+
613
+ ' Create a pop-up box and ask if they want to register cscript as the default host.
614
+ Set ShellObject = WScript.CreateObject("WScript.Shell")
615
+ ' -1 is the time to wait. 0 means wait forever.
616
+ RegCScript = ShellObject.PopUp(GetLocalizedResource("StrRes265"), 0, GetLocalizedResource("StrRes266"), RegPopupType)
617
+
618
+ If (Err.Number <> 0) Then
619
+ ReportError ()
620
+ WScript.Echo GetLocalizedResource("StrRes72") & WScript.ScriptName & """"
621
+ WScript.Quit (GENERAL_FAILURE)
622
+ WScript.Quit (Err.Number)
623
+ End If
624
+
625
+ ' Check to see if the user pressed yes or no. Yes is 6, no is 7
626
+ If (RegCScript = 6) Then
627
+ ShellObject.RegWrite "HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
628
+ ShellObject.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
629
+ ' Check if PathExt already existed
630
+ CurrentPathExt = ShellObject.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT")
631
+ If Err.Number = &H80070002 Then
632
+ Err.Clear
633
+ Set EnvObject = ShellObject.Environment("PROCESS")
634
+ CurrentPathExt = EnvObject.Item("PATHEXT")
635
+ End If
636
+
637
+ ShellObject.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT", CurrentPathExt & ";.VBS", "REG_SZ"
638
+
639
+ If (Err.Number <> 0) Then
640
+ ReportError ()
641
+ WScript.Echo GetLocalizedResource("StrRes73")
642
+ WScript.Quit (Err.Number)
643
+ Else
644
+ WScript.Echo GetLocalizedResource("StrRes74")
645
+ End If
646
+ Else
647
+ WScript.Echo GetLocalizedResource("StrRes75")
648
+ End If
649
+
650
+ Dim ProcString
651
+ Dim ArgIndex
652
+ Dim ArgObj
653
+ Dim Result
654
+
655
+ ProcString = "Cscript //nologo " & WScript.ScriptFullName
656
+
657
+ Set ArgObj = WScript.Arguments
658
+
659
+ For ArgIndex = 0 To ArgCount - 1
660
+ ProcString = ProcString & " " & Args(ArgIndex)
661
+ Next
662
+
663
+ 'Now, run the original executable under CScript.exe
664
+ Result = ShellObject.Run(ProcString, 0, True)
665
+
666
+ WScript.Quit (Result)
667
+ End If
668
+
669
+ End Sub
670
+
671
+
672
+ ''''''''''''''''''''''''''
673
+ '
674
+ ' SetCommand Function
675
+ '
676
+ ' Sets the value of a property in the metabase.
677
+ '
678
+ ''''''''''''''''''''''''''
679
+ Function SetCommand()
680
+ Dim IIsObject
681
+ Dim IIsObjectPath
682
+ Dim IIsSchemaObject
683
+ Dim IIsSchemaPath
684
+ Dim ObjectPath
685
+ Dim ObjectParameter
686
+ Dim MachineName
687
+ Dim ValueIndex
688
+ Dim ValueList
689
+ Dim ValueDisplay
690
+ Dim ValueDisplayLen
691
+ Dim ValueDataType
692
+
693
+ Dim ValueData
694
+
695
+ Dim ObjectDataType
696
+
697
+ On Error Resume Next
698
+
699
+ SetCommand = 0 ' Assume Success
700
+
701
+ If ArgCount < 3 Then
702
+ WScript.Echo GetLocalizedResource("StrRes76")
703
+ WScript.Quit (GENERAL_FAILURE)
704
+ End If
705
+
706
+ ObjectPath = Args(1)
707
+ SanitizePath ObjectPath
708
+ MachineName = SeparateMachineName(ObjectPath)
709
+ ObjectParameter = SplitParam(ObjectPath)
710
+
711
+ ' Some Property Types have special needs - like ServerCommand.
712
+ ' Check to see if this is a special command. If it is, then process it special.
713
+ If (IsSpecialSetProperty(ObjectParameter)) Then
714
+ SetCommand = DoSpecialSetProp(ObjectPath, ObjectParameter, MachineName)
715
+ Exit Function
716
+ End If
717
+
718
+ If ObjectPath = "" Then
719
+ IIsObjectPath = "IIS://" & MachineName
720
+ Else
721
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
722
+ End If
723
+ Set IIsObject = GetObject(IIsObjectPath)
724
+
725
+ If (Err.Number <> 0) Then
726
+ ReportError ()
727
+ WScript.Echo GetLocalizedResource("StrRes77") & ObjectPath
728
+ WScript.Quit (Err.Number)
729
+ End If
730
+
731
+ ' Get the Schema of the property and determine if it's multivalued
732
+ IIsSchemaPath = "IIS://" & MachineName & "/Schema/" & ObjectParameter
733
+ Set IIsSchemaObject = GetObject(IIsSchemaPath)
734
+
735
+ If (Err.Number <> 0) Then
736
+ ReportError ()
737
+ WScript.Echo GetLocalizedResource("StrRes78") & IIsSchemaPath
738
+ WScript.Quit (Err.Number)
739
+ End If
740
+
741
+ ObjectDataType = UCase(IIsSchemaObject.Syntax)
742
+ SanitizePath ObjectDataType
743
+
744
+ Select Case (ObjectDataType)
745
+
746
+ Case "STRING"
747
+ ValueList = Args(2)
748
+ IIsObject.Put ObjectParameter, (ValueList)
749
+
750
+ Case "EXPANDSZ"
751
+ ValueList = Args(2)
752
+ IIsObject.Put ObjectParameter, (ValueList)
753
+
754
+ Case "INTEGER"
755
+ ' Added to convert hex values to integers
756
+ ValueData = Args(2)
757
+
758
+ If (UCase(Left(ValueData, 2))) = "0X" Then
759
+ ValueData = "&h" & Right(ValueData, Len(ValueData) - 2)
760
+ End If
761
+
762
+ ValueList = StringTo32BitUnsignedInteger(ValueData)
763
+ IIsObject.Put ObjectParameter, (ValueList)
764
+
765
+ Case "BOOLEAN"
766
+ ValueList = CBool(Args(2))
767
+ IIsObject.Put ObjectParameter, (ValueList)
768
+
769
+ Case "LIST"
770
+ ReDim ValueList(ArgCount - 3)
771
+ For ValueIndex = 2 To ArgCount - 1
772
+ ValueList(ValueIndex - 2) = Args(ValueIndex)
773
+ Next
774
+
775
+ IIsObject.Put ObjectParameter, (ValueList)
776
+
777
+ Case Else
778
+ WScript.Echo GetLocalizedResource("StrRes79") & IIsSchemaObject.Syntax
779
+
780
+ End Select
781
+
782
+ IIsObject.Setinfo
783
+
784
+ If (Err.Number <> 0) Then
785
+ ReportError ()
786
+ WScript.Echo GetLocalizedResource("StrRes80") & ObjectParameter
787
+ WScript.Quit (Err.Number)
788
+ End If
789
+
790
+ ' The function call succeeded, so display the output
791
+ ' Set up the initial part of the display - the property name and data type
792
+ ValueDisplay = ObjectParameter
793
+ ValueDisplayLen = Len(ValueDisplay)
794
+
795
+ If (ValueDisplayLen < SpacerSize) Then
796
+ ValueDisplay = ValueDisplay & (Right(Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & ObjectDataType & ") "
797
+ Else
798
+ ValueDisplay = ValueDisplay & ": " & "(" & TypeName(ValueList) & ") "
799
+ End If
800
+
801
+ ' Create the rest of the display - The actual data
802
+ If (IIsSchemaObject.MultiValued) Then
803
+ For ValueIndex = 0 To UBound(ValueList)
804
+ ValueDisplay = ValueDisplay & """" & ValueList(ValueIndex) & """ "
805
+ Next
806
+ Else
807
+ If (UCase(IIsSchemaObject.Syntax) = "STRING") Then
808
+ If (IsSecureProperty(ObjectParameter,MachineName) = True) Then
809
+ ValueDisplay = ValueDisplay & """" & "**********" & """"
810
+ Else
811
+ ValueDisplay = ValueDisplay & """" & ValueList & """"
812
+ End If
813
+ ElseIf (UCase(IIsSchemaObject.Syntax) = "INTEGER") Then
814
+ ValueDisplay = ValueDisplay & UnsignedIntegerToString(ValueList)
815
+ Else
816
+ ValueDisplay = ValueDisplay & ValueList
817
+ End If
818
+ End If
819
+
820
+ ' Display the output
821
+ WScript.Echo ValueDisplay
822
+
823
+ SetCommand = 0 ' Success
824
+
825
+ End Function
826
+
827
+
828
+ ''''''''''''''''''''''''''
829
+ '
830
+ ' GetCommand Function
831
+ '
832
+ ' Gets the value of a property in the metabase.
833
+ '
834
+ ''''''''''''''''''''''''''
835
+ Function GetCommand()
836
+
837
+ Dim IIsObject
838
+ Dim IIsObjectPath
839
+ Dim IIsSchemaObject
840
+ Dim IIsSchemaPath
841
+ Dim ObjectPath
842
+ Dim ObjectParameter
843
+ Dim MachineName
844
+ Dim ValueIndex
845
+ Dim ValueList
846
+ Dim ValueListArray
847
+ Dim ValueDisplay
848
+ Dim ValueDisplayLen
849
+ Dim NewObjectparameter
850
+
851
+ Dim DataPathList
852
+ Dim DataPath
853
+
854
+ On Error Resume Next
855
+
856
+ GetCommand = 0 ' Assume Success
857
+
858
+ If ArgCount <> 2 Then
859
+ WScript.Echo GetLocalizedResource("StrRes81")
860
+ WScript.Quit (GENERAL_FAILURE)
861
+ End If
862
+
863
+ ObjectPath = Args(1)
864
+
865
+ SanitizePath ObjectPath
866
+ MachineName = SeparateMachineName(ObjectPath)
867
+ ObjectParameter = SplitParam(ObjectPath)
868
+
869
+ NewObjectparameter = MapSpecGetParamName(ObjectParameter)
870
+ ObjectParameter = NewObjectparameter
871
+
872
+ If (IsSpecialGetProperty(ObjectParameter)) Then
873
+ GetCommand = DoSpecialGetProp(ObjectPath, ObjectParameter, MachineName)
874
+ Exit Function
875
+ End If
876
+
877
+ If ObjectPath = "" Then
878
+ IIsObjectPath = "IIS://" & MachineName
879
+ Else
880
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
881
+ End If
882
+
883
+ Set IIsObject = GetObject(IIsObjectPath)
884
+
885
+ If (Err.Number <> 0) Then
886
+ ReportError ()
887
+ WScript.Echo GetLocalizedResource("StrRes82") & ObjectPath
888
+ WScript.Quit (Err.Number)
889
+ End If
890
+
891
+ ' Get the Schema of the property and determine if it's multivalued
892
+ IIsSchemaPath = "IIS://" & MachineName & "/Schema/" & ObjectParameter
893
+ Set IIsSchemaObject = GetObject(IIsSchemaPath)
894
+
895
+ If (Err.Number <> 0) Then
896
+ ReportError ()
897
+ WScript.Echo GetLocalizedResource("StrRes83") & IIsSchemaPath
898
+ WScript.Quit (Err.Number)
899
+ End If
900
+
901
+ ' First, attempt to retrieve the property - this will tell us
902
+ ' if you are even allowed to set the property at this node.
903
+ ' Retrieve the property
904
+ ValueList = IIsObject.Get(ObjectParameter)
905
+ If (Err.Number <> 0) Then
906
+ ReportError ()
907
+ WScript.Echo GetLocalizedResource("StrRes84") & ObjectParameter
908
+ WScript.Echo GetLocalizedResource("StrRes85")
909
+ WScript.Quit (Err.Number)
910
+ End If
911
+
912
+ ' Test to see if the property is ACTUALLY set at this node
913
+ DataPathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_INHERIT)
914
+ If Err.Number <> 0 Then DataPathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_NO_INHERIT)
915
+ Err.Clear
916
+
917
+ ' If the data is not set anywhere, then stop the madness
918
+ If (UBound(DataPathList) < 0) Then
919
+ WScript.Echo GetLocalizedResource("StrRes86") & ObjectParameter & GetLocalizedResource("StrRes87")
920
+ WScript.Quit (&H80005006) ' end with property not set error
921
+ End If
922
+
923
+ DataPath = DataPathList(0)
924
+ SanitizePath DataPath
925
+
926
+ ' Test to see if the item is actually set HERE
927
+ If UCase(DataPath) <> UCase(IIsObjectPath) Then
928
+ WScript.Echo GetLocalizedResource("StrRes86") & ObjectParameter & GetLocalizedResource("StrRes87")
929
+ WScript.Quit (&H80005006) ' end with property not set error
930
+ End If
931
+
932
+ ' Set up the initial part of the display - the property name and data type
933
+ ValueDisplay = ObjectParameter
934
+ ValueDisplayLen = Len(ValueDisplay)
935
+
936
+ If (ValueDisplayLen < SpacerSize) Then
937
+ ValueDisplay = ValueDisplay & (Right(Spacer, SpacerSize - ValueDisplayLen)) & ": " & "(" & UCase(IIsSchemaObject.Syntax) & ") "
938
+ Else
939
+ ValueDisplay = ValueDisplay & ": " & "(" & TypeName(ValueList) & ") "
940
+ End If
941
+
942
+ ' Create the rest of the display - The actual data
943
+ If (IIsSchemaObject.MultiValued) Then
944
+ WScript.Echo ValueDisplay & " (" & UBound (ValueList) + 1 & GetLocalizedResource("StrRes90")
945
+
946
+ For ValueIndex = 0 To UBound(ValueList)
947
+ WScript.Echo " """ & ValueList(ValueIndex) & """"
948
+ Next
949
+ Else
950
+ If (UCase(IIsSchemaObject.Syntax) = "STRING") Then
951
+ If (IsSecureProperty(ObjectParameter,MachineName) = True) Then
952
+ ValueDisplay = ValueDisplay & """" & "**********" & """"
953
+ Else
954
+ ValueDisplay = ValueDisplay & """" & ValueList & """"
955
+ End If
956
+
957
+ ElseIf (UCase(IIsSchemaObject.Syntax) = "BINARY") Then
958
+ ValueListArray = IIsObject.Get(ObjectParameter)
959
+
960
+ ValueList = "0x"
961
+
962
+ For ValueIndex = 0 To UBound(ValueListArray)
963
+ ValueList = ValueList & ValueListArray(ValueIndex) & " "
964
+ Next
965
+
966
+ ValueDisplay = ValueDisplay & ValueList
967
+
968
+ ElseIf (UCase(IIsSchemaObject.Syntax) = "INTEGER") Then
969
+ ValueDisplay = ValueDisplay & UnsignedIntegerToString(ValueList)
970
+ Else
971
+ 'WScript.Echo ValueList
972
+ ValueDisplay = ValueDisplay & ValueList
973
+ End If
974
+
975
+ ' Display the output
976
+ WScript.Echo ValueDisplay
977
+ End If
978
+
979
+ If (Err.Number <> 0) Then
980
+ ReportError ()
981
+ WScript.Echo GetLocalizedResource("StrRes91") & ObjectParameter
982
+ WScript.Quit (Err.Number)
983
+ End If
984
+
985
+ GetCommand = 0 ' Success
986
+
987
+ End Function
988
+
989
+
990
+ ''''''''''''''''''''''''''
991
+ '
992
+ ' EnumCommand Function
993
+ '
994
+ ' Enumerates all properties at a path in the metabase.
995
+ '
996
+ ''''''''''''''''''''''''''
997
+ Function EnumCommand(Recurse, StartPath)
998
+
999
+ On Error Resume Next
1000
+
1001
+ Dim IIsObject
1002
+ Dim IIsObjectPath
1003
+ Dim IIsSchemaObject
1004
+ Dim IIsSchemaPath
1005
+ Dim ObjectPath
1006
+ Dim MachineName
1007
+ Dim ValueIndex
1008
+ Dim ValueList
1009
+ Dim ValueListArray
1010
+ Dim ValueString
1011
+ Dim PropertyName
1012
+ Dim PropertyAttribObj
1013
+ Dim PropertyListSet
1014
+ Dim PropertyList
1015
+ Dim PropertyObjPath
1016
+ Dim PropertyObject
1017
+ Dim ChildObject
1018
+ Dim ChildObjectName
1019
+ Dim EnumPathsOnly
1020
+ Dim EnumAllData
1021
+ Dim ErrMask
1022
+ Dim IsInherit
1023
+
1024
+ Dim PropertyDataType
1025
+
1026
+ Dim SpecialResult
1027
+
1028
+ Dim PathOnlyOption
1029
+ PathOnlyOption = "/P"
1030
+
1031
+ EnumCommand = 0 ' Assume Success
1032
+ EnumPathsOnly = False ' Assume that the user wants all of the data items
1033
+ EnumAllData = False ' Assume that the user wants only the actual data items
1034
+
1035
+ If (ArgCount = 1) Then
1036
+ ObjectPath = ""
1037
+ EnumPathsOnly = False
1038
+ ArgCount = 2
1039
+ ElseIf (ArgCount = 2) Then
1040
+ If UCase(Args(1)) = PathOnlyOption Then
1041
+ ObjectPath = ""
1042
+ EnumPathsOnly = True
1043
+ Else
1044
+ ObjectPath = Args(1)
1045
+ EnumPathsOnly = False
1046
+ End If
1047
+ ElseIf (ArgCount = 3) Then
1048
+
1049
+ If UCase(Args(1)) = PathOnlyOption Then
1050
+ ObjectPath = Args(2)
1051
+ EnumPathsOnly = True
1052
+ ElseIf UCase(Args(2)) = PathOnlyOption Then
1053
+ ObjectPath = Args(1)
1054
+ EnumPathsOnly = True
1055
+ Else
1056
+ WScript.Echo GetLocalizedResource("StrRes92")
1057
+ WScript.Quit (GENERAL_FAILURE)
1058
+ End If
1059
+ Else
1060
+ WScript.Echo GetLocalizedResource("StrRes93")
1061
+ WScript.Quit (GENERAL_FAILURE)
1062
+ End If
1063
+
1064
+ If StartPath <> "" Then ObjectPath = StartPath
1065
+
1066
+ SanitizePath ObjectPath
1067
+ MachineName = SeparateMachineName(ObjectPath)
1068
+
1069
+ IIsObjectPath = "IIS://" & MachineName
1070
+ If (ObjectPath <> "") Then
1071
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
1072
+ End If
1073
+
1074
+ Set IIsObject = GetObject(IIsObjectPath)
1075
+
1076
+ If (Err.Number <> 0) Then
1077
+ WScript.Echo
1078
+ ReportError ()
1079
+ WScript.Echo GetLocalizedResource("StrRes94") & ObjectPath
1080
+ WScript.Quit (Err.Number)
1081
+ End If
1082
+
1083
+ ' Get the Schema of the object and enumerate through all of the properties
1084
+ IIsSchemaPath = IIsObject.Schema
1085
+ Set IIsSchemaObject = GetObject(IIsSchemaPath)
1086
+
1087
+ If (Err.Number <> 0) Then
1088
+ WScript.Echo
1089
+ ReportError ()
1090
+ WScript.Echo GetLocalizedResource("StrRes95") & IIsSchemaPath
1091
+ WScript.Quit (Err.Number)
1092
+ End If
1093
+
1094
+ ReDim PropertyListSet(1)
1095
+ PropertyListSet(0) = IIsSchemaObject.MandatoryProperties
1096
+ PropertyListSet(1) = IIsSchemaObject.OptionalProperties
1097
+
1098
+ If (Err.Number <> 0) Then
1099
+ WScript.Echo
1100
+ ReportError ()
1101
+ WScript.Echo GetLocalizedResource("StrRes96") & IIsSchemaPath
1102
+ WScript.Quit (Err.Number)
1103
+ End If
1104
+
1105
+ ' This now checks for an empty OptionalProperties list
1106
+ If TypeName (PropertyListSet(1)) <> "Variant()" Then
1107
+ WScript.Echo
1108
+ WScript.Echo GetLocalizedResource("StrRes97")
1109
+ WScript.Echo
1110
+ ElseIf (UBound (PropertyListSet(1)) = -1) Then
1111
+ WScript.Echo
1112
+ WScript.Echo GetLocalizedResource("StrRes98")
1113
+ WScript.Echo
1114
+ End If
1115
+
1116
+ If (Not EnumPathsOnly) Then
1117
+ For Each PropertyList In PropertyListSet
1118
+
1119
+ For Each PropertyName In PropertyList
1120
+ If Err <> 0 Then
1121
+ Exit For
1122
+ End If
1123
+
1124
+ ' Test to see if the property is even set at this node
1125
+ IsInherit = False
1126
+ Err.Clear
1127
+ Set PropertyAttribObj = IIsObject.GetPropertyAttribObj(PropertyName)
1128
+ If (Err.Number = 0) Then
1129
+
1130
+ If (PropertyAttribObj.IsInherit) Then
1131
+ IsInherit = True
1132
+ End If
1133
+ Err.Clear
1134
+
1135
+ If (IsInherit = False) Or (EnumAllData) Then
1136
+ ' If the above statement is true, then the data exists here or the user wants it anyway.
1137
+
1138
+ PropertyObjPath = "IIS://" & MachineName & "/Schema/" & PropertyName
1139
+ Set PropertyObject = GetObject(PropertyObjPath)
1140
+
1141
+ If (Err.Number <> 0) Then
1142
+ WScript.Echo
1143
+ ReportError ()
1144
+ WScript.Echo GetLocalizedResource("StrRes99") & PropertyObjPath
1145
+ WScript.Echo GetLocalizedResource("StrRes100") & PropertyName
1146
+ WScript.Echo "PropertyObjPath: " & PropertyObjPath
1147
+ WScript.Echo
1148
+ EnumCommand = Err.Number
1149
+ Err.Clear
1150
+ End If
1151
+
1152
+ ValueList = ""
1153
+ ValueListArray = ""
1154
+
1155
+ PropertyDataType = UCase(PropertyObject.Syntax)
1156
+ Select Case PropertyDataType
1157
+ Case "STRING"
1158
+ ValueList = IIsObject.Get(PropertyName)
1159
+ If (IsSecureProperty(PropertyName,MachineName) = True) Then
1160
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & """" & "**********" & """"
1161
+ Else
1162
+ If (Len(PropertyName) < SpacerSize) Then
1163
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") """ & ValueList & """"
1164
+ Else
1165
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ")" & """" & ValueList & """"
1166
+ End If
1167
+ End If
1168
+
1169
+ Case "EXPANDSZ"
1170
+ ValueList = IIsObject.Get(PropertyName)
1171
+ If (Len(PropertyName) < SpacerSize) Then
1172
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") """ & ValueList & """"
1173
+ Else
1174
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") """ & ValueList & """"
1175
+ End If
1176
+
1177
+ Case "BINARY"
1178
+ ValueListArray = IIsObject.Get(PropertyName)
1179
+
1180
+ ValueList = "0x"
1181
+
1182
+ For ValueIndex = 0 To UBound(ValueListArray)
1183
+ ValueList = ValueList & ValueListArray(ValueIndex) & " "
1184
+ Next
1185
+
1186
+ If (Len(PropertyName) < SpacerSize) Then
1187
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & ValueList
1188
+ Else
1189
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & ValueList
1190
+ End If
1191
+
1192
+ Case "INTEGER"
1193
+ ValueList = IIsObject.Get(PropertyName)
1194
+ If (Len(PropertyName) < SpacerSize) Then
1195
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & UnsignedIntegerToString(ValueList)
1196
+ Else
1197
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & UnsignedIntegerToString(ValueList)
1198
+ End If
1199
+
1200
+ Case "BOOLEAN"
1201
+ ValueList = IIsObject.Get(PropertyName)
1202
+ If (Len(PropertyName) < SpacerSize) Then
1203
+ WScript.Echo PropertyName & Left(Spacer, Len(Spacer) - Len(PropertyName)) & ": " & "(" & PropertyDataType & ") " & ValueList
1204
+ Else
1205
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") " & ValueList
1206
+ End If
1207
+
1208
+ Case "LIST"
1209
+ ValueList = IIsObject.Get(PropertyName)
1210
+ If (Len(PropertyName) < SpacerSize) Then
1211
+ WScript.Echo PropertyName & _
1212
+ Left(Spacer, Len(Spacer) - Len(PropertyName)) & _
1213
+ ": " & "(" & PropertyDataType & ") (" & _
1214
+ (UBound (ValueList) + 1) & GetLocalizedResource("StrRes102")
1215
+ Else
1216
+ WScript.Echo PropertyName & " : " & "(" & PropertyDataType & ") (" & (UBound (ValueList) + 1) & GetLocalizedResource("StrRes102")
1217
+ End If
1218
+ ValueString = ""
1219
+
1220
+ For ValueIndex = 0 To UBound(ValueList)
1221
+ WScript.Echo " """ & ValueList(ValueIndex) & """"
1222
+ Next
1223
+ WScript.Echo
1224
+
1225
+ Case Else
1226
+
1227
+ If (IsSpecialGetProperty(PropertyName)) Then
1228
+
1229
+ SpecialResult = DoSpecialGetProp(ObjectPath, PropertyName, MachineName)
1230
+ Err.Clear
1231
+
1232
+ Else
1233
+ WScript.Echo
1234
+ WScript.Echo GetLocalizedResource("StrRes103") & """" & PropertyObject.Syntax & """" & GetLocalizedResource("StrRes104") & PropertyName
1235
+ ReportError
1236
+ WScript.Echo
1237
+ End If
1238
+
1239
+ End Select
1240
+
1241
+ End If ' End if data exists at the current node
1242
+
1243
+ Else ' Error during GetPropertyAttribObj
1244
+ Err.Clear 'ignore and go to the next property
1245
+ End If
1246
+
1247
+ If (Err.Number <> 0) Then
1248
+ WScript.Echo
1249
+ ReportError ()
1250
+ WScript.Echo GetLocalizedResource("StrRes105") & PropertyObjPath
1251
+ WScript.Echo GetLocalizedResource("StrRes100") & PropertyName
1252
+ WScript.Echo "PropertyObjPath: " & PropertyObjPath
1253
+ ' If there is an ADS error, just ignore it and move on
1254
+ ' otherwise, quit
1255
+ If ((Err.Number) >= &H80005000) And ((Err.Number) < &H80006000) Then
1256
+ Err.Clear
1257
+ WScript.Echo GetLocalizedResource("StrRes108")
1258
+ Else
1259
+ WScript.Quit (Err.Number)
1260
+ End If
1261
+ WScript.Echo
1262
+ End If
1263
+ Next
1264
+ Next
1265
+
1266
+ If (Err.Number <> 0) Then
1267
+ WScript.Echo GetLocalizedResource("StrRes109")
1268
+ ReportError ()
1269
+ WScript.Echo
1270
+ EnumCommand = Err.Number
1271
+ Err.Clear
1272
+ End If
1273
+
1274
+ End If ' End if (Not EnumPathsOnly)
1275
+
1276
+ ' Now, enumerate the data paths
1277
+ For Each ChildObject In IIsObject
1278
+ If (Err.Number <> 0) Then Exit For
1279
+
1280
+ ChildObjectName = Right(ChildObject.AdsPath, Len(ChildObject.AdsPath) - 6)
1281
+ ChildObjectName = Right(ChildObjectName, Len(ChildObjectName) - InStr(ChildObjectName, "/") + 1)
1282
+ WScript.Echo "[" & ChildObjectName & "]"
1283
+ If (Recurse = True) And (ChildObjectName <> Args(1)) Then
1284
+ EnumCommand = EnumCommand(True, ChildObjectName)
1285
+ End If
1286
+ Next
1287
+
1288
+ If (Err.Number <> 0) Then
1289
+ WScript.Echo GetLocalizedResource("StrRes111")
1290
+ ReportError ()
1291
+ WScript.Echo
1292
+ EnumCommand = Err.Number
1293
+ Err.Clear
1294
+ End If
1295
+
1296
+ WScript.Echo ""
1297
+
1298
+ End Function
1299
+
1300
+
1301
+ ''''''''''''''''''''''''''
1302
+ '
1303
+ ' Create Function
1304
+ '
1305
+ ' Creates a path in the metabase. An additional parameter that is
1306
+ ' not found in mdutil is optional. That is the Object Type (KeyType)
1307
+ ' If this is not specified, the object type will be assumed to be
1308
+ ' IIsObject (which, of course, is useless).
1309
+ '
1310
+ ''''''''''''''''''''''''''
1311
+ Function CreateCommand(ObjectTypeParam)
1312
+
1313
+ On Error Resume Next
1314
+
1315
+ Dim IIsObject
1316
+ Dim IIsObjectPath
1317
+ Dim IIsObjectRelativePath
1318
+ Dim NewObject
1319
+ Dim ObjectTypeName
1320
+ Dim ParentObjPath
1321
+ Dim ParentObjSize
1322
+ Dim FullAdsParentPath
1323
+ Dim MachineName
1324
+ Dim OpenErr
1325
+
1326
+ ' Set the return code - assume success
1327
+ CreateCommand = 0
1328
+
1329
+ ' Setup the parameters
1330
+ If (ArgCount = 2) Then
1331
+ If (ObjectTypeParam = "") Then
1332
+ ObjectTypeName = "IIsObject"
1333
+ Else
1334
+ ObjectTypeName = ObjectTypeParam
1335
+ End If
1336
+ ElseIf (ArgCount = 3) Then
1337
+ ObjectTypeName = Args(2)
1338
+ Else
1339
+ WScript.Echo GetLocalizedResource("StrRes112")
1340
+ DisplayHelpMessage
1341
+ WScript.Quit (GENERAL_FAILURE)
1342
+ End If
1343
+
1344
+ IIsObjectPath = Args(1)
1345
+ SanitizePath IIsObjectPath
1346
+ MachineName = SeparateMachineName(IIsObjectPath)
1347
+
1348
+ ' Parse the path and determine if the parent exists.
1349
+ ParentObjSize = InStrRev(IIsObjectPath, "/")
1350
+ ParentObjPath = ""
1351
+
1352
+ If ParentObjSize <> 0 Then
1353
+ ParentObjPath = Left(IIsObjectPath, ParentObjSize - 1)
1354
+ IIsObjectRelativePath = Right(IIsObjectPath, Len(IIsObjectPath) - ParentObjSize)
1355
+ Else
1356
+ IIsObjectRelativePath = IIsObjectPath
1357
+ End If
1358
+
1359
+ If ParentObjPath <> "" Then
1360
+ FullAdsParentPath = "IIS://" & MachineName & "/" & ParentObjPath
1361
+ Else
1362
+ FullAdsParentPath = "IIS://" & MachineName
1363
+ End If
1364
+ 'debug
1365
+ 'WScript.Echo "Last Error: " & Err.Number
1366
+ 'WScript.Echo "MachineName: " & MachineName
1367
+ 'WScript.Echo "ParentObjPath: " & ParentObjPath
1368
+ 'WScript.Echo "FullAdsParentPath: " & FullAdsParentPath
1369
+ 'WScript.Echo "IIsObjectPath: " & IIsObjectPath
1370
+ 'WScript.Echo "IIsObjectRelativePath: " & IIsObjectRelativePath
1371
+ 'WScript.Echo "ObjectTypeName: " & ObjectTypeName
1372
+
1373
+ ' First, attempt to open the parent path and add the new path.
1374
+ Set IIsObject = GetObject(FullAdsParentPath)
1375
+ If Err.Number <> 0 Then
1376
+ OpenErr = Err.Number
1377
+ OpenErrDesc = Err.Description
1378
+ Err.Clear
1379
+ ' Attempt to get the Computer Object (IIS://LocalHost)
1380
+ Set IIsObject = GetObject("IIS://" & MachineName)
1381
+ If Err.Number <> 0 Then
1382
+ WScript.Echo
1383
+ ReportError ()
1384
+ WScript.Echo GetLocalizedResource("StrRes120") & IIsObjectPath
1385
+ WScript.Quit (Err.Number)
1386
+ End If
1387
+ End If
1388
+
1389
+ 'Now, attempt to add the new object.
1390
+ If (OpenErr <> 0) Then
1391
+ Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectPath)
1392
+ Else
1393
+ Set NewObject = IIsObject.Create(ObjectTypeName, IIsObjectRelativePath)
1394
+ End If
1395
+
1396
+ If Err.Number <> 0 Then
1397
+ WScript.Echo
1398
+ ReportError ()
1399
+ WScript.Echo GetLocalizedResource("StrRes121") & IIsObjectPath
1400
+ WScript.Quit (Err.Number)
1401
+ End If
1402
+
1403
+ NewObject.Setinfo
1404
+
1405
+ If Err.Number <> 0 Then
1406
+ WScript.Echo
1407
+ ReportError ()
1408
+ WScript.Echo GetLocalizedResource("StrRes121") & IIsObjectPath
1409
+ WScript.Quit (Err.Number)
1410
+ End If
1411
+
1412
+
1413
+ ' Now, if the parent object was not created, generate a warning.
1414
+ If OpenErr <> 0 Then
1415
+ WScript.Echo
1416
+ WScript.Echo GetLocalizedResource("StrRes123") & ParentObjPath & GetLocalizedResource("StrRes124")
1417
+ WScript.Echo GetLocalizedResource("StrRes125")
1418
+ WScript.Echo GetLocalizedResource("StrRes126")
1419
+ WScript.Echo GetLocalizedResource("StrRes127")
1420
+ WScript.Echo
1421
+ CreateCommand = GENERAL_WARNING
1422
+ End If
1423
+
1424
+ If UCase(ObjectTypeName) = "IISOBJECT" Then
1425
+ WScript.Echo
1426
+ WScript.Echo GetLocalizedResource("StrRes128")
1427
+ WScript.Echo GetLocalizedResource("StrRes129")
1428
+ WScript.Echo GetLocalizedResource("StrRes130")
1429
+ WScript.Echo
1430
+ CreateCommand = GENERAL_WARNING
1431
+ End If
1432
+
1433
+ WScript.Echo GetLocalizedResource("StrRes131") & IIsObjectPath & """"
1434
+ End Function
1435
+
1436
+ ''''''''''''''''''''''''''
1437
+ '
1438
+ ' Delete Function
1439
+ '
1440
+ ' Deletes a path in the metabase.
1441
+ '
1442
+ ''''''''''''''''''''''''''
1443
+ Function DeleteCommand()
1444
+
1445
+ On Error Resume Next
1446
+
1447
+ Dim IIsObject
1448
+ Dim IIsObjectPath
1449
+
1450
+ Dim ObjectPath
1451
+ Dim ObjectParam
1452
+ Dim MachineName
1453
+
1454
+ Dim DummyVariant
1455
+ Dim DeletePathOnly
1456
+ ReDim DummyVariant(0)
1457
+ DummyVariant(0) = "Bogus"
1458
+
1459
+ ' Set the return code - assume success
1460
+ DeleteCommand = 0
1461
+
1462
+ ' Setup the parameters
1463
+ If (ArgCount <> 2) Then
1464
+ WScript.Echo GetLocalizedResource("StrRes132")
1465
+ WScript.Quit (GENERAL_FAILURE)
1466
+ End If
1467
+
1468
+ ObjectPath = Args(1)
1469
+
1470
+ ' Check and see if the user is specifically asking to delete the path
1471
+ DeletePathOnly = False
1472
+ If Right(ObjectPath, 1) = "/" Then
1473
+ DeletePathOnly = True
1474
+ End If
1475
+
1476
+ ' Sanitize the path and split parameter and path
1477
+ SanitizePath ObjectPath
1478
+ MachineName = SeparateMachineName(ObjectPath)
1479
+ ObjectParam = SplitParam(ObjectPath)
1480
+
1481
+ ' Open the parent object
1482
+ IIsObjectPath = "IIS://" & MachineName
1483
+ If ObjectPath <> "" Then
1484
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
1485
+ End If
1486
+
1487
+ Set IIsObject = GetObject(IIsObjectPath)
1488
+
1489
+ If Err.Number <> 0 Then
1490
+ WScript.Echo
1491
+ ReportError ()
1492
+ WScript.Echo GetLocalizedResource("StrRes133") & ObjectPath & "/" & ObjectParam
1493
+ WScript.Quit (Err.Number)
1494
+ End If
1495
+
1496
+ ' If they did not specifically ask to delete the path, then attempt to delete the property
1497
+ If Not DeletePathOnly Then
1498
+ ' Try to delete the property
1499
+
1500
+ ' ADS_PROPERTY_CLEAR used to be defined, but it isn't anymore.
1501
+ 'IIsObject.PutEx ADS_PROPERTY_CLEAR, ObjectParam, DummyVariant
1502
+ IIsObject.PutEx "1", ObjectParam, DummyVariant
1503
+
1504
+ ' If it succeeded, then just return, else continue and try to delete the path
1505
+ If Err.Number = 0 Then
1506
+ IIsObject.SetInfo
1507
+ WScript.Echo GetLocalizedResource("StrRes134") & ObjectParam & """"
1508
+ Exit Function
1509
+ End If
1510
+ Err.Clear
1511
+ End If
1512
+
1513
+ ' Try to just delete the path
1514
+ IIsObject.Delete "IIsObject", ObjectParam
1515
+
1516
+ If Err.Number <> 0 Then
1517
+ WScript.Echo
1518
+ ReportError ()
1519
+ WScript.Echo GetLocalizedResource("StrRes135") & ObjectPath & "/" & ObjectParam
1520
+ WScript.Quit (Err.Number)
1521
+ End If
1522
+
1523
+ WScript.Echo GetLocalizedResource("StrRes136") & ObjectPath & "/" & ObjectParam & """"
1524
+
1525
+ Exit Function
1526
+
1527
+ End Function
1528
+
1529
+
1530
+ ''''''''''''''''''''''''''
1531
+ '
1532
+ ' EnumAllCommand
1533
+ '
1534
+ ' Enumerates all data and all properties in the metabase under the current path.
1535
+ '
1536
+ ''''''''''''''''''''''''''
1537
+ Function EnumAllCommand()
1538
+ On Error Resume Next
1539
+
1540
+ WScript.Echo GetLocalizedResource("StrRes137")
1541
+
1542
+ End Function
1543
+
1544
+
1545
+ ''''''''''''''''''''''''''
1546
+ '
1547
+ ' CopyMoveCommand
1548
+ '
1549
+ ' Copies a path in the metabase to another path.
1550
+ '
1551
+ ''''''''''''''''''''''''''
1552
+ Function CopyMoveCommand(bCopyFlag)
1553
+ On Error Resume Next
1554
+
1555
+ Dim SrcObjectPath
1556
+ Dim DestObjectPath
1557
+ Dim DestObject
1558
+
1559
+ Dim ParentObjectPath
1560
+ Dim ParentRelativePath
1561
+ Dim ParentObject
1562
+
1563
+ Dim MachineName
1564
+
1565
+ Dim TmpDestLeftPath
1566
+ Dim TmpSrcLeftPath
1567
+
1568
+ CopyMoveCommand = 0 ' Assume Success
1569
+
1570
+ If ArgCount <> 3 Then
1571
+ WScript.Echo GetLocalizedResource("StrRes138")
1572
+ WScript.Quit (GENERAL_FAILURE)
1573
+ End If
1574
+
1575
+ SrcObjectPath = Args(1)
1576
+ DestObjectPath = Args(2)
1577
+
1578
+ SanitizePath SrcObjectPath
1579
+ SanitizePath DestObjectPath
1580
+ MachineName = SeparateMachineName(SrcObjectPath)
1581
+ ParentObjectPath = "IIS://" & MachineName
1582
+
1583
+ ' Extract the left part of the paths until there are no more left parts to extract
1584
+ Do
1585
+ TmpSrcLeftPath = SplitLeftPath(SrcObjectPath)
1586
+ TmpDestLeftPath = SplitLeftPath(DestObjectPath)
1587
+
1588
+ If (SrcObjectPath = "") Or (DestObjectPath = "") Then
1589
+ SrcObjectPath = TmpSrcLeftPath & "/" & SrcObjectPath
1590
+ DestObjectPath = TmpDestLeftPath & "/" & DestObjectPath
1591
+ Exit Do
1592
+ End If
1593
+
1594
+ If (TmpSrcLeftPath <> TmpDestLeftPath) Then
1595
+ SrcObjectPath = TmpSrcLeftPath & "/" & SrcObjectPath
1596
+ DestObjectPath = TmpDestLeftPath & "/" & DestObjectPath
1597
+ Exit Do
1598
+ End If
1599
+
1600
+ ParentObjectPath = ParentObjectPath & "/" & TmpSrcLeftPath
1601
+ ParentRelativePath = ParentRelativePath & "/" & TmpSrcLeftPath
1602
+
1603
+ Loop
1604
+
1605
+ SanitizePath SrcObjectPath
1606
+ SanitizePath DestObjectPath
1607
+ SanitizePath ParentObjectPath
1608
+
1609
+ ' Now, open the parent object and Copy/Move the objects
1610
+ Set ParentObject = GetObject(ParentObjectPath)
1611
+
1612
+ If (Err.Number <> 0) Then
1613
+ ReportError ()
1614
+ WScript.Echo GetLocalizedResource("StrRes139") & ParentObjectPath
1615
+ WScript.Quit (Err.Number)
1616
+ End If
1617
+
1618
+ If (bCopyFlag) Then
1619
+ Set DestObject = ParentObject.CopyHere(SrcObjectPath, DestObjectPath)
1620
+ Else
1621
+ Set DestObject = ParentObject.MoveHere(SrcObjectPath, DestObjectPath)
1622
+ End If
1623
+
1624
+ If (Err.Number <> 0) Then
1625
+ ReportError ()
1626
+ WScript.Echo GetLocalizedResource("StrRes140")
1627
+ WScript.Quit (Err.Number)
1628
+ End If
1629
+
1630
+ If (bCopyFlag) Then
1631
+ WScript.Echo GetLocalizedResource("StrRes141") & ParentRelativePath & "/" & SrcObjectPath & GetLocalizedResource("StrRes142") & ParentRelativePath & "/" & DestObjectPath
1632
+ Else
1633
+ WScript.Echo GetLocalizedResource("StrRes143") & ParentRelativePath & "/" & SrcObjectPath & GetLocalizedResource("StrRes142") & ParentRelativePath & "/" & DestObjectPath
1634
+ End If
1635
+
1636
+ End Function
1637
+
1638
+ ''''''''''''''''''''''''''
1639
+ '
1640
+ ' StartServerCommand
1641
+ '
1642
+ ' Starts a server in the metabase.
1643
+ '
1644
+ ''''''''''''''''''''''''''
1645
+ Function StartServerCommand()
1646
+
1647
+ On Error Resume Next
1648
+
1649
+ Dim IIsObject
1650
+ Dim IIsObjectPath
1651
+ Dim ObjectPath
1652
+ Dim MachineName
1653
+
1654
+ If ArgCount <> 2 Then
1655
+ WScript.Echo GetLocalizedResource("StrRes145")
1656
+ WScript.Quit (GENERAL_FAILURE)
1657
+ End If
1658
+
1659
+ ObjectPath = Args(1)
1660
+ SanitizePath ObjectPath
1661
+ MachineName = SeparateMachineName(ObjectPath)
1662
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
1663
+
1664
+ Set IIsObject = GetObject(IIsObjectPath)
1665
+
1666
+ If (Err.Number <> 0) Then
1667
+ ReportError ()
1668
+ WScript.Echo GetLocalizedResource("StrRes146") & ObjectPath
1669
+ WScript.Quit (Err.Number)
1670
+ End If
1671
+ 'debug
1672
+ 'WScript.echo "About to start server. Last Error: " & Err.Number
1673
+ IIsObject.Start
1674
+ 'WScript.echo "After starting server. Last Error: " & Err.Number
1675
+ If (Err.Number <> 0) Then
1676
+ ReportError ()
1677
+ WScript.Echo GetLocalizedResource("StrRes147") & ObjectPath
1678
+ WScript.Quit (Err.Number)
1679
+ End If
1680
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes149")
1681
+
1682
+ End Function
1683
+
1684
+ ''''''''''''''''''''''''''
1685
+ '
1686
+ ' StopServerCommand
1687
+ '
1688
+ ' Stops a server in the metabase.
1689
+ '
1690
+ ''''''''''''''''''''''''''
1691
+ Function StopServerCommand()
1692
+
1693
+ On Error Resume Next
1694
+
1695
+ Dim IIsObject
1696
+ Dim IIsObjectPath
1697
+ Dim ObjectPath
1698
+ Dim MachineName
1699
+
1700
+ If ArgCount <> 2 Then
1701
+ WScript.Echo GetLocalizedResource("StrRes150")
1702
+ WScript.Quit (GENERAL_FAILURE)
1703
+ End If
1704
+
1705
+ ObjectPath = Args(1)
1706
+ SanitizePath ObjectPath
1707
+ MachineName = SeparateMachineName(ObjectPath)
1708
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
1709
+
1710
+ Set IIsObject = GetObject(IIsObjectPath)
1711
+
1712
+ If (Err.Number <> 0) Then
1713
+ ReportError ()
1714
+ WScript.Echo GetLocalizedResource("StrRes151") & ObjectPath
1715
+ WScript.Quit (Err.Number)
1716
+ End If
1717
+
1718
+ IIsObject.Stop
1719
+ If (Err.Number <> 0) Then
1720
+ ReportError ()
1721
+ WScript.Echo GetLocalizedResource("StrRes152") & ObjectPath
1722
+ WScript.Quit (Err.Number)
1723
+ End If
1724
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes154")
1725
+
1726
+ End Function
1727
+
1728
+ ''''''''''''''''''''''''''
1729
+ '
1730
+ ' PauseServerCommand
1731
+ '
1732
+ ' Pauses a server in the metabase.
1733
+ '
1734
+ ''''''''''''''''''''''''''
1735
+ Function PauseServerCommand()
1736
+
1737
+ On Error Resume Next
1738
+
1739
+ Dim IIsObject
1740
+ Dim IIsObjectPath
1741
+ Dim ObjectPath
1742
+ Dim MachineName
1743
+
1744
+ If ArgCount <> 2 Then
1745
+ WScript.Echo GetLocalizedResource("StrRes155")
1746
+ WScript.Quit (GENERAL_FAILURE)
1747
+ End If
1748
+
1749
+ ObjectPath = Args(1)
1750
+ SanitizePath ObjectPath
1751
+ MachineName = SeparateMachineName(ObjectPath)
1752
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
1753
+
1754
+ Set IIsObject = GetObject(IIsObjectPath)
1755
+
1756
+ If (Err.Number <> 0) Then
1757
+ ReportError ()
1758
+ WScript.Echo GetLocalizedResource("StrRes156") & ObjectPath
1759
+ WScript.Quit (Err.Number)
1760
+ End If
1761
+
1762
+ IIsObject.Pause
1763
+ If (Err.Number <> 0) Then
1764
+ ReportError ()
1765
+ WScript.Echo GetLocalizedResource("StrRes157") & ObjectPath
1766
+ WScript.Quit (Err.Number)
1767
+ End If
1768
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes159")
1769
+
1770
+ End Function
1771
+
1772
+ ''''''''''''''''''''''''''
1773
+ '
1774
+ ' ContinueServerCommand
1775
+ '
1776
+ ' Continues a server in the metabase.
1777
+ '
1778
+ ''''''''''''''''''''''''''
1779
+ Function ContinueServerCommand()
1780
+
1781
+ On Error Resume Next
1782
+
1783
+ Dim IIsObject
1784
+ Dim IIsObjectPath
1785
+ Dim ObjectPath
1786
+ Dim MachineName
1787
+
1788
+ If ArgCount <> 2 Then
1789
+ WScript.Echo GetLocalizedResource("StrRes160")
1790
+ WScript.Quit (GENERAL_FAILURE)
1791
+ End If
1792
+
1793
+ ObjectPath = Args(1)
1794
+ SanitizePath ObjectPath
1795
+ MachineName = SeparateMachineName(ObjectPath)
1796
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
1797
+
1798
+ Set IIsObject = GetObject(IIsObjectPath)
1799
+
1800
+ If (Err.Number <> 0) Then
1801
+ ReportError ()
1802
+ WScript.Echo GetLocalizedResource("StrRes161") & ObjectPath
1803
+ WScript.Quit (Err.Number)
1804
+ End If
1805
+
1806
+ IIsObject.Continue
1807
+ If (Err.Number <> 0) Then
1808
+ ReportError ()
1809
+ WScript.Echo GetLocalizedResource("StrRes162") & ObjectPath
1810
+ WScript.Quit (Err.Number)
1811
+ End If
1812
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes164")
1813
+
1814
+ End Function
1815
+
1816
+
1817
+ Function FindData()
1818
+ ' FindData will accept 1 parameter from the command line - the node and
1819
+ ' property to search for (i.e. w3svc/1/ServerComment)
1820
+
1821
+ On Error Resume Next
1822
+
1823
+ Dim ObjectPath
1824
+ Dim ObjectParameter
1825
+ Dim NewObjectparameter
1826
+ Dim MachineName
1827
+
1828
+ Dim IIsObjectPath
1829
+ Dim IIsObject
1830
+
1831
+ Dim Path
1832
+ Dim PathList
1833
+ Dim I
1834
+
1835
+ FindData = 0 ' Assume Success
1836
+
1837
+ If ArgCount <> 2 Then
1838
+ WScript.Echo GetLocalizedResource("StrRes165")
1839
+ WScript.Quit (GENERAL_FAILURE)
1840
+ End If
1841
+
1842
+ ObjectPath = Args(1)
1843
+
1844
+ SanitizePath ObjectPath
1845
+ MachineName = SeparateMachineName(ObjectPath)
1846
+ ObjectParameter = SplitParam(ObjectPath)
1847
+
1848
+ ' Since people may still want to use MDUTIL parameter names
1849
+ ' we should still do the GET translation of parameter names.
1850
+ NewObjectparameter = MapSpecGetParamName(ObjectParameter)
1851
+ ObjectParameter = NewObjectparameter
1852
+
1853
+ If ObjectPath = "" Then
1854
+ IIsObjectPath = "IIS://" & MachineName
1855
+ Else
1856
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
1857
+ End If
1858
+
1859
+ Set IIsObject = GetObject(IIsObjectPath)
1860
+
1861
+ If (Err.Number <> 0) Then
1862
+ ReportError ()
1863
+ WScript.Echo GetLocalizedResource("StrRes166") & ObjectPath
1864
+ WScript.Quit (Err.Number)
1865
+ End If
1866
+
1867
+ ' Now, list out all the places where this property exists.
1868
+ PathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_INHERIT)
1869
+ If Err.Number <> 0 Then PathList = IIsObject.GetDataPaths(ObjectParameter, IIS_DATA_NO_INHERIT)
1870
+
1871
+ If (Err.Number <> 0) Then
1872
+ ReportError ()
1873
+ WScript.Echo GetLocalizedResource("StrRes167") & ObjectPath
1874
+ WScript.Quit (Err.Number)
1875
+ End If
1876
+
1877
+ If UBound(PathList) < 0 Then
1878
+ WScript.Echo GetLocalizedResource("StrRes168") & ObjectParameter & GetLocalizedResource("StrRes169") & ObjectPath
1879
+ Else
1880
+ WScript.Echo GetLocalizedResource("StrRes168") & ObjectParameter & GetLocalizedResource("StrRes171")
1881
+
1882
+ For Each Path In PathList
1883
+ Path = Right(Path, Len(Path) - 6)
1884
+ Path = Right(Path, Len(Path) - InStr(Path, "/"))
1885
+ WScript.Echo " " & Path
1886
+ Next
1887
+ End If
1888
+
1889
+ If (Err.Number <> 0) Then
1890
+ ReportError ()
1891
+ WScript.Echo GetLocalizedResource("StrRes172") & ObjectPath
1892
+ WScript.Quit (Err.Number)
1893
+ End If
1894
+
1895
+ End Function
1896
+
1897
+ '''''''''''''''''''''
1898
+ '
1899
+ ' MimeMapGet
1900
+ '
1901
+ ' Special function for displaying a MimeMap property
1902
+ '
1903
+ '''''''''''''''''''''
1904
+ Function MimeMapGet(ObjectPath, MachineName)
1905
+ On Error Resume Next
1906
+
1907
+ Dim MimePath
1908
+
1909
+ Dim MimeMapList
1910
+ Dim MimeMapObject
1911
+ Dim MimeEntry
1912
+ Dim MimeEntryIndex
1913
+
1914
+ Dim MimeStr
1915
+ Dim MimeOutPutStr
1916
+
1917
+ Dim DataPathList
1918
+ Dim DataPath
1919
+
1920
+ MimeMapGet = 0 ' Assume Success
1921
+
1922
+ MimePath = "IIS://" & MachineName
1923
+ If ObjectPath <> "" Then MimePath = MimePath & "/" & ObjectPath
1924
+
1925
+ ' Get the object that contains the mimemap
1926
+ Set MimeMapObject = GetObject(MimePath)
1927
+ If (Err.Number <> 0) Then
1928
+ ReportError ()
1929
+ WScript.Echo GetLocalizedResource("StrRes173") & ObjectPath
1930
+ WScript.Quit (Err.Number)
1931
+ End If
1932
+
1933
+ ' Test to see if the property is ACTUALLY set at this node
1934
+ DataPathList = MimeMapObject.GetDataPaths("MimeMap", IIS_DATA_INHERIT)
1935
+ If Err.Number <> 0 Then DataPathList = IIsObject.GetDataPaths(MimeMap, IIS_DATA_NO_INHERIT)
1936
+ Err.Clear
1937
+
1938
+ ' If the data is not set anywhere, then stop the madness
1939
+ If (UBound(DataPathList) < 0) Then
1940
+ MimeMapGet = &H80005006 ' end with property not set error
1941
+ Exit Function
1942
+ End If
1943
+
1944
+ DataPath = DataPathList(0)
1945
+ SanitizePath DataPath
1946
+
1947
+ ' Test to see if the item is actually set HERE
1948
+ If UCase(DataPath) <> UCase(MimePath) Then
1949
+ MimeMapGet = &H80005006 ' end with property not set error
1950
+ Exit Function
1951
+ End If
1952
+
1953
+ ' Get the mime map list from the object
1954
+ MimeMapList = MimeMapObject.Get("MimeMap")
1955
+ If (Err.Number <> 0) Then
1956
+ ReportError ()
1957
+ WScript.Echo GetLocalizedResource("StrRes173") & ObjectPath
1958
+ WScript.Quit (Err.Number)
1959
+ End If
1960
+
1961
+ MimeOutPutStr = "MimeMap : (MimeMapList) "
1962
+
1963
+ ' Enumerate the Mime Entries
1964
+ For MimeEntryIndex = 0 To UBound(MimeMapList)
1965
+ Set MimeEntry = MimeMapList(MimeEntryIndex)
1966
+ MimeOutPutStr = MimeOutPutStr & """" & MimeEntry.Extension & "," & MimeEntry.MimeType & """ "
1967
+ Next
1968
+
1969
+ If (Err.Number <> 0) Then
1970
+ ReportError ()
1971
+ WScript.Echo GetLocalizedResource("StrRes175")
1972
+ WScript.Quit (Err.Number)
1973
+ End If
1974
+
1975
+ WScript.Echo MimeOutPutStr
1976
+
1977
+ End Function
1978
+
1979
+
1980
+
1981
+ Function MimeMapSet(ObjectPath, ObjectParameter, MachineName)
1982
+ On Error Resume Next
1983
+
1984
+ Dim MimePath
1985
+
1986
+ Dim MimeEntryIndex
1987
+ Dim MimeMapList()
1988
+ Dim MimeMapObject
1989
+ Dim MimeEntry
1990
+
1991
+ Dim MimeStr
1992
+ Dim MimeOutPutStr
1993
+
1994
+ MimeMapSet = 0 ' Assume Success
1995
+
1996
+ ' First, check the number of args
1997
+ If ArgCount < 3 Then
1998
+ WScript.Echo GetLocalizedResource("StrRes176")
1999
+ WScript.Quit (GENERAL_FAILURE)
2000
+ End If
2001
+
2002
+
2003
+ MimePath = "IIS://" & MachineName
2004
+ If ObjectPath <> "" Then MimePath = MimePath & "/" & ObjectPath
2005
+
2006
+ ' Get the object that contains the mimemap
2007
+ Set MimeMapObject = GetObject(MimePath)
2008
+ If (Err.Number <> 0) Then
2009
+ ReportError ()
2010
+ WScript.Echo GetLocalizedResource("StrRes177") & ObjectPath
2011
+ WScript.Quit (Err.Number)
2012
+ End If
2013
+
2014
+ ' Create a new MimeMapList of Mime Entries
2015
+ ReDim MimeMapList(ArgCount - 3)
2016
+
2017
+ MimeOutPutStr = "MimeMap : (MimeMapList) "
2018
+
2019
+ ' Fill the list with mime entries
2020
+ For MimeEntryIndex = 0 To UBound(MimeMapList)
2021
+
2022
+ MimeStr = Args(2 + MimeEntryIndex)
2023
+ MimeOutPutStr = MimeOutPutStr & """" & MimeStr & """ "
2024
+
2025
+ Set MimeEntry = CreateObject("MimeMap")
2026
+
2027
+ MimeEntry.MimeType = Right (MimeStr, Len(MimeStr) - InStr(MimeStr, ","))
2028
+ MimeEntry.Extension = Left(MimeStr, InStr(MimeStr, ",") - 1)
2029
+
2030
+ Set MimeMapList(MimeEntryIndex) = MimeEntry
2031
+ Next
2032
+
2033
+ If (Err.Number <> 0) Then
2034
+ ReportError ()
2035
+ WScript.Echo GetLocalizedResource("StrRes175")
2036
+ WScript.Quit (Err.Number)
2037
+ End If
2038
+
2039
+ MimeMapObject.MimeMap = MimeMapList
2040
+ MimeMapObject.Setinfo
2041
+
2042
+ If (Err.Number <> 0) Then
2043
+ ReportError ()
2044
+ WScript.Echo GetLocalizedResource("StrRes179")
2045
+ WScript.Quit (Err.Number)
2046
+ End If
2047
+
2048
+ WScript.Echo MimeOutPutStr
2049
+
2050
+ End Function
2051
+
2052
+ ''''''''''''''''''''''''''
2053
+ '
2054
+ ' IsSpecialGetProperty
2055
+ '
2056
+ ' Checks to see if the property requires special processing in order to
2057
+ ' display its contents.
2058
+ '
2059
+ ''''''''''''''''''''''''''
2060
+ Function IsSpecialGetProperty(ObjectParameter)
2061
+
2062
+ On Error Resume Next
2063
+
2064
+ Select Case UCase(ObjectParameter)
2065
+ Case "MIMEMAP"
2066
+ IsSpecialGetProperty = True
2067
+ Case Else
2068
+ IsSpecialGetProperty = False
2069
+ End Select
2070
+
2071
+ End Function
2072
+
2073
+ ''''''''''''''''''''''''''
2074
+ '
2075
+ ' DoSpecialGetProp
2076
+ '
2077
+ ' Checks to see if the property requires special processing in order to
2078
+ ' display its contents.
2079
+ '
2080
+ ''''''''''''''''''''''''''
2081
+ Function DoSpecialGetProp(ObjectPath, ObjectParameter, MachineName)
2082
+
2083
+ On Error Resume Next
2084
+
2085
+ Select Case UCase(ObjectParameter)
2086
+ Case "MIMEMAP"
2087
+ DoSpecialGetProp = MimeMapGet(ObjectPath, MachineName)
2088
+ Case Else
2089
+ DoSpecialGetProp = False
2090
+ End Select
2091
+
2092
+ End Function
2093
+
2094
+
2095
+
2096
+ ''''''''''''''''''''''''''
2097
+ '
2098
+ ' IsSpecialSetProperty
2099
+ '
2100
+ ' Checks to see if the property is a type that needs to be handled
2101
+ ' specially for compatibility with mdutil
2102
+ '
2103
+ ''''''''''''''''''''''''''
2104
+ Function IsSpecialSetProperty(ObjectParameter)
2105
+
2106
+ On Error Resume Next
2107
+
2108
+ Select Case UCase(ObjectParameter)
2109
+ Case "APPPOOLCOMMAND"
2110
+ IsSpecialSetProperty = True
2111
+ Case "SERVERCOMMAND"
2112
+ IsSpecialSetProperty = True
2113
+ Case "ACCESSPERM"
2114
+ IsSpecialSetProperty = True
2115
+ Case "VRPATH"
2116
+ IsSpecialSetProperty = True
2117
+ Case "AUTHORIZATION"
2118
+ IsSpecialSetProperty = True
2119
+ Case "MIMEMAP"
2120
+ IsSpecialSetProperty = True
2121
+ Case Else
2122
+ IsSpecialSetProperty = False
2123
+ End Select
2124
+ End Function
2125
+
2126
+ ''''''''''''''''''''''''''
2127
+ '
2128
+ ' DoSpecialSetProp
2129
+ '
2130
+ ' Handles datatypes that need to be handled
2131
+ ' specially for compatibility with mdutil
2132
+ '
2133
+ ''''''''''''''''''''''''''
2134
+ Function DoSpecialSetProp(ObjectPath, ObjectParameter, MachineName)
2135
+ Dim IIsObjectPath
2136
+ Dim IIsObject
2137
+ Dim ValueList
2138
+ Dim ValueDisplay
2139
+ Dim PermIndex
2140
+
2141
+ On Error Resume Next
2142
+
2143
+ DoSpecialSetProp = 0 ' Assume Success
2144
+ Select Case UCase(ObjectParameter)
2145
+ Case "SERVERCOMMAND"
2146
+
2147
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
2148
+ Set IIsObject = GetObject(IIsObjectPath)
2149
+
2150
+ If (Err.Number <> 0) Then
2151
+ ReportError ()
2152
+ WScript.Echo GetLocalizedResource("StrRes180") & ObjectPath
2153
+ WScript.Quit (Err.Number)
2154
+ End If
2155
+
2156
+ If (IIsObject.KeyType <> "IIsWebServer") Then
2157
+ ReportError ()
2158
+ WScript.Echo GetLocalizedResource("StrRes181")
2159
+ WScript.Quit (GENERAL_FAILURE)
2160
+ End If
2161
+
2162
+ ValueList = CLng(Args(2))
2163
+ Select Case ValueList
2164
+ Case 1
2165
+ IIsObject.Start
2166
+ If (Err.Number <> 0) Then
2167
+ ReportError ()
2168
+ WScript.Echo GetLocalizedResource("StrRes182") & ObjectPath
2169
+ WScript.Quit (Err.Number)
2170
+ End If
2171
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes184")
2172
+ Case 2
2173
+ IIsObject.Stop
2174
+ If (Err.Number <> 0) Then
2175
+ ReportError ()
2176
+ WScript.Echo GetLocalizedResource("StrRes185") & ObjectPath
2177
+ WScript.Quit (Err.Number)
2178
+ End If
2179
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes187")
2180
+ Case 3
2181
+ IIsObject.Pause
2182
+ If (Err.Number <> 0) Then
2183
+ ReportError ()
2184
+ WScript.Echo GetLocalizedResource("StrRes188") & ObjectPath
2185
+ WScript.Quit (Err.Number)
2186
+ End If
2187
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes190")
2188
+ Case 4
2189
+ IIsObject.Continue
2190
+ If (Err.Number <> 0) Then
2191
+ ReportError ()
2192
+ WScript.Echo GetLocalizedResource("StrRes191") & ObjectPath
2193
+ WScript.Quit (Err.Number)
2194
+ End If
2195
+ WScript.Echo GetLocalizedResource("StrRes148") & ObjectPath & GetLocalizedResource("StrRes193")
2196
+ Case Else
2197
+ WScript.Echo GetLocalizedResource("StrRes194") & ValueList
2198
+ DoSpecialSetProp = GENERAL_FAILURE
2199
+ End Select
2200
+ Exit Function
2201
+
2202
+ Case "APPPOOLCOMMAND"
2203
+
2204
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
2205
+ Set IIsObject = GetObject(IIsObjectPath)
2206
+
2207
+ If (Err.Number <> 0) Then
2208
+ ReportError ()
2209
+ WScript.Echo GetLocalizedResource("StrRes195") & ObjectPath
2210
+ WScript.Quit (Err.Number)
2211
+ End If
2212
+
2213
+ If (IIsObject.KeyType <> "IIsApplicationPool") Then
2214
+ ReportError ()
2215
+ WScript.Echo GetLocalizedResource("StrRes196")
2216
+ WScript.Quit (GENERAL_FAILURE)
2217
+ End If
2218
+
2219
+ ValueList = CLng(Args(2))
2220
+ Select Case ValueList
2221
+ Case 1
2222
+ IIsObject.Start
2223
+ If (Err.Number <> 0) Then
2224
+ ReportError ()
2225
+ WScript.Echo GetLocalizedResource("StrRes197") & ObjectPath
2226
+ WScript.Quit (Err.Number)
2227
+ End If
2228
+ WScript.Echo GetLocalizedResource("StrRes198") & ObjectPath & GetLocalizedResource("StrRes199")
2229
+ Case 2
2230
+ IIsObject.Stop
2231
+ If (Err.Number <> 0) Then
2232
+ ReportError ()
2233
+ WScript.Echo GetLocalizedResource("StrRes200") & ObjectPath
2234
+ WScript.Quit (Err.Number)
2235
+ End If
2236
+ WScript.Echo GetLocalizedResource("StrRes198") & ObjectPath & GetLocalizedResource("StrRes201")
2237
+ Case Else
2238
+ WScript.Echo GetLocalizedResource("StrRes203") & ValueList
2239
+ DoSpecialSetProp = GENERAL_FAILURE
2240
+ End Select
2241
+ Exit Function
2242
+
2243
+ Case "ACCESSPERM"
2244
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
2245
+ Set IIsObject = GetObject(IIsObjectPath)
2246
+
2247
+ If (Err.Number <> 0) Then
2248
+ ReportError ()
2249
+ WScript.Echo GetLocalizedResource("StrRes204") & ObjectPath
2250
+ WScript.Quit (Err.Number)
2251
+ End If
2252
+
2253
+ ' Set the access flags to None, first, and then add them back, as necessary
2254
+ IIsObject.AccessFlags = 0
2255
+
2256
+ ' Set up the display output
2257
+ ValueDisplay = "AccessFlags (AccessPerm)" & (Right(Spacer, SpacerSize - Len("AccessFlags (AccessPerm)")) & ": " & "(" & TypeName(IIsObject.AccessFlags) & ") ")
2258
+
2259
+ ' Attempt to convert parameter to number
2260
+ Dim APValue
2261
+ Dim TempValStr
2262
+
2263
+ TempValStr = Args(2)
2264
+
2265
+ ' Check for Hex
2266
+ If (UCase(Left(Args(2), 2)) = "0X") Then
2267
+ TempValStr = "&H" & Right(TempValStr, Len(TempValStr) - 2)
2268
+ End If
2269
+
2270
+ APValue = CLng(TempValStr)
2271
+
2272
+ If (Err.Number = 0) Then
2273
+ IIsObject.AccessFlags = APValue
2274
+ ValueDisplay = ValueDisplay & " " & APValue & " (0x" & Hex(APValue) & ")"
2275
+ Else
2276
+ Err.Clear
2277
+ For PermIndex = 2 To ArgCount - 1
2278
+ Select Case UCase(Args(PermIndex))
2279
+ Case "READ"
2280
+ IIsObject.AccessRead = True
2281
+ ValueDisplay = ValueDisplay & " Read"
2282
+ Case "WRITE"
2283
+ IIsObject.AccessWrite = True
2284
+ ValueDisplay = ValueDisplay & " Write"
2285
+ Case "EXECUTE"
2286
+ IIsObject.AccessExecute = True
2287
+ ValueDisplay = ValueDisplay & " Execute"
2288
+ Case "SCRIPT"
2289
+ IIsObject.AccessScript = True
2290
+ ValueDisplay = ValueDisplay & " Script"
2291
+ Case Else
2292
+ WScript.Echo GetLocalizedResource("StrRes205") & Args(PermIndex)
2293
+ WScript.Quit (GENERAL_FAILURE)
2294
+ End Select
2295
+ Next
2296
+ End If
2297
+
2298
+ If (Err.Number <> 0) Then
2299
+ ReportError ()
2300
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2301
+ WScript.Quit (Err.Number)
2302
+ End If
2303
+
2304
+ IIsObject.Setinfo
2305
+
2306
+ If (Err.Number <> 0) Then
2307
+ ReportError ()
2308
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2309
+ WScript.Quit (Err.Number)
2310
+ End If
2311
+
2312
+ ' Send the current settings to the screen
2313
+ WScript.Echo ValueDisplay
2314
+
2315
+ Case "VRPATH"
2316
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
2317
+ Set IIsObject = GetObject(IIsObjectPath)
2318
+
2319
+ If (Err.Number <> 0) Then
2320
+ ReportError ()
2321
+ WScript.Echo GetLocalizedResource("StrRes208") & ObjectPath
2322
+ WScript.Quit (Err.Number)
2323
+ End If
2324
+
2325
+ ' Set the access flags to None, first, and then add them back, as necessary
2326
+ IIsObject.Path = Args(2)
2327
+
2328
+ If (Err.Number <> 0) Then
2329
+ ReportError ()
2330
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2331
+ WScript.Quit (Err.Number)
2332
+ End If
2333
+
2334
+ ' Set up the display output
2335
+ ValueDisplay = "Path (VRPath)" & (Right(Spacer, SpacerSize - Len("Path (VRPath)")) & ": " & "(" & TypeName(IIsObject.Path) & ") " & IIsObject.Path)
2336
+
2337
+ IIsObject.Setinfo
2338
+
2339
+ If (Err.Number <> 0) Then
2340
+ ReportError ()
2341
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2342
+ WScript.Quit (Err.Number)
2343
+ End If
2344
+
2345
+ ' Send the current settings to the screen
2346
+ WScript.Echo ValueDisplay
2347
+
2348
+ Case "AUTHORIZATION"
2349
+ IIsObjectPath = "IIS://" & MachineName & "/" & ObjectPath
2350
+ Set IIsObject = GetObject(IIsObjectPath)
2351
+
2352
+ If (Err.Number <> 0) Then
2353
+ ReportError ()
2354
+ WScript.Echo GetLocalizedResource("StrRes208") & ObjectPath
2355
+ WScript.Quit (Err.Number)
2356
+ End If
2357
+
2358
+ ' Set the auth flags to None, first, and then add them back, as necessary
2359
+ IIsObject.AuthFlags = 0
2360
+
2361
+ ' Set up the display output
2362
+ ValueDisplay = GetLocalizedResource("StrRes270") & (Right(Spacer, SpacerSize - Len(GetLocalizedResource("StrRes270"))) & ": " & "(" & TypeName(IIsObject.AuthFlags) & ") ")
2363
+
2364
+ For PermIndex = 2 To ArgCount - 1
2365
+ Select Case UCase(Args(PermIndex))
2366
+ Case "NT"
2367
+ IIsObject.AuthNTLM = True
2368
+ ValueDisplay = ValueDisplay & " NT"
2369
+ Case "ANONYMOUS"
2370
+ IIsObject.AuthAnonymous = True
2371
+ ValueDisplay = ValueDisplay & GetLocalizedResource("StrRes271")
2372
+ Case "BASIC"
2373
+ IIsObject.AuthBasic = True
2374
+ ValueDisplay = ValueDisplay & GetLocalizedResource("StrRes272")
2375
+ Case Else
2376
+ WScript.Echo GetLocalizedResource("StrRes205") & Args(PermIndex)
2377
+ WScript.Quit (GENERAL_FAILURE)
2378
+ End Select
2379
+ Next
2380
+
2381
+ If (Err.Number <> 0) Then
2382
+ ReportError ()
2383
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2384
+ WScript.Quit (Err.Number)
2385
+ End If
2386
+
2387
+ IIsObject.Setinfo
2388
+
2389
+ If (Err.Number <> 0) Then
2390
+ ReportError ()
2391
+ WScript.Echo GetLocalizedResource("StrRes206") & ObjectPath
2392
+ WScript.Quit (Err.Number)
2393
+ End If
2394
+
2395
+ ' Send the current settings to the screen
2396
+ WScript.Echo ValueDisplay
2397
+
2398
+ Case "MIMEMAP"
2399
+ DoSpecialSetProp = MimeMapSet(ObjectPath, ObjectParameter, MachineName)
2400
+ ' Case "FILTER"
2401
+ ' DoSpecialSetProp = FiltersSet()
2402
+ Case Else
2403
+ DoSpecialSetProp = GENERAL_FAILURE
2404
+ End Select
2405
+ End Function
2406
+
2407
+ ''''''''''''''''''''''''''''''
2408
+ '
2409
+ ' Function SeparateMachineName
2410
+ '
2411
+ ' This function will get the machine name from the Path parameter
2412
+ ' that was passed into the script. It will also alter the passed in
2413
+ ' path so that it contains only the rest of the path - not the machine
2414
+ ' name. If there is no machine name in the path, then the script
2415
+ ' will assume LocalHost.
2416
+ '
2417
+ ''''''''''''''''''''''''''''''
2418
+ Function SeparateMachineName(Path)
2419
+ On Error Resume Next
2420
+
2421
+ ' Temporarily, just return LocalHost
2422
+ ' SeparateMachineName = "LocalHost"
2423
+
2424
+ SeparateMachineName = TargetServer
2425
+
2426
+ Exit Function
2427
+ End Function
2428
+
2429
+ ''''''''''''''''''''''''''''''
2430
+ '
2431
+ ' Function MapSpecGetParamName
2432
+ '
2433
+ ' Some parameters in MDUTIL are named differently in ADSI.
2434
+ ' This function maps the improtant parameter names to ADSI
2435
+ ' names.
2436
+ '
2437
+ ''''''''''''''''''''''''''''''
2438
+ Function MapSpecGetParamName(ObjectParameter)
2439
+ On Error Resume Next
2440
+
2441
+ Select Case UCase(ObjectParameter)
2442
+ Case "ACCESSPERM"
2443
+ WScript.Echo GetLocalizedResource("StrRes215") & ObjectParameter & GetLocalizedResource("StrRes216")
2444
+ WScript.Echo GetLocalizedResource("StrRes217")
2445
+ MapSpecGetParamName = "AccessFlags"
2446
+ Case "VRPATH"
2447
+ MapSpecGetParamName = "Path"
2448
+ Case "AUTHORIZATION"
2449
+ WScript.Echo GetLocalizedResource("StrRes215") & ObjectParameter & GetLocalizedResource("StrRes221")
2450
+ WScript.Echo GetLocalizedResource("StrRes222")
2451
+ MapSpecGetParamName = "AuthFlags"
2452
+ Case Else
2453
+ ' Do nothing - the parameter doesn't map to anything special
2454
+ MapSpecGetParamName = ObjectParameter
2455
+ End Select
2456
+ End Function
2457
+
2458
+ Sub ReportError()
2459
+ ' On Error Resume Next
2460
+
2461
+ Dim ErrorDescription
2462
+
2463
+ Select Case (Err.Number)
2464
+ Case &H80070003
2465
+ ErrorDescription = GetLocalizedResource("StrRes267")
2466
+ Case &H80070005
2467
+ ErrorDescription = GetLocalizedResource("StrRes268")
2468
+ Case &H80070094
2469
+ ErrorDescription = GetLocalizedResource("StrRes269")
2470
+ Case Else
2471
+ ErrorDescription = Err.Description
2472
+ End Select
2473
+
2474
+ WScript.Echo ErrorDescription
2475
+ WScript.Echo GetLocalizedResource("StrRes223") & Err.Number & " (0x" & Hex(Err.Number) & ")"
2476
+ End Sub
2477
+
2478
+
2479
+
2480
+
2481
+ Function SplitParam(ObjectPath)
2482
+ ' Note: Assume the string has been sanitized (no leading or trailing slashes)
2483
+ On Error Resume Next
2484
+
2485
+ Dim SlashIndex
2486
+ Dim TempParam
2487
+ Dim ObjectPathLen
2488
+
2489
+ SplitParam = "" ' Assume no parameter
2490
+ ObjectPathLen = Len(ObjectPath)
2491
+
2492
+ ' Separate the path of the node from the parameter
2493
+ SlashIndex = InStrRev(ObjectPath, "/")
2494
+
2495
+ If (SlashIndex = 0) Or (SlashIndex = ObjectPathLen) Then
2496
+ TempParam = ObjectPath
2497
+ ObjectPath = "" ' ObjectParameter is more important
2498
+ Else
2499
+ TempParam = ObjectPath
2500
+ ObjectPath = Left(ObjectPath, SlashIndex - 1)
2501
+ TempParam = Right(TempParam, Len(TempParam) - SlashIndex)
2502
+ End If
2503
+
2504
+ SplitParam = TempParam
2505
+
2506
+ If (Err.Number <> 0) Then
2507
+ ReportError ()
2508
+ WScript.Echo GetLocalizedResource("StrRes225") & ObjectPath
2509
+ WScript.Quit (Err.Number)
2510
+ End If
2511
+
2512
+ End Function
2513
+
2514
+
2515
+
2516
+ Function SplitLeftPath(ObjectPath)
2517
+ ' Note: Assume the string has been sanitized (no leading or trailing slashes)
2518
+ On Error Resume Next
2519
+
2520
+ Dim SlashIndex
2521
+ Dim TmpLeftPath
2522
+ Dim ObjectPathLen
2523
+
2524
+ SplitLeftPath = "" ' Assume no LeftPath
2525
+ ObjectPathLen = Len(ObjectPath)
2526
+
2527
+ ' Separate the left part of the path from the remaining path
2528
+ SlashIndex = InStr(ObjectPath, "/")
2529
+
2530
+ If (SlashIndex = 0) Or (SlashIndex = ObjectPathLen) Then
2531
+ TmpLeftPath = ObjectPath
2532
+ ObjectPath = ""
2533
+ Else
2534
+ TmpLeftPath = Left(ObjectPath, SlashIndex - 1)
2535
+ ObjectPath = Right(ObjectPath, Len(ObjectPath) - SlashIndex)
2536
+ End If
2537
+
2538
+ SplitLeftPath = TmpLeftPath
2539
+
2540
+ If (Err.Number <> 0) Then
2541
+ ReportError ()
2542
+ WScript.Echo GetLocalizedResource("StrRes234") & ObjectPath
2543
+ WScript.Quit (Err.Number)
2544
+ End If
2545
+
2546
+ End Function
2547
+
2548
+
2549
+
2550
+
2551
+ Sub SanitizePath(ObjectPath)
2552
+ On Error Resume Next
2553
+
2554
+ ' Remove WhiteSpace
2555
+ Do While (Left(ObjectPath, 1) = " ")
2556
+ ObjectPath = Right(ObjectPath, Len(ObjectPath) - 1)
2557
+ Loop
2558
+
2559
+ Do While (Right(ObjectPath, 1) = " ")
2560
+ ObjectPath = Left(ObjectPath, Len(ObjectPath) - 1)
2561
+ Loop
2562
+
2563
+ ' Replace all occurrences of \ with /
2564
+ ObjectPath = Replace(ObjectPath, "\", "/")
2565
+
2566
+ ' Remove leading and trailing slashes
2567
+ If Left(ObjectPath, 1) = "/" Then
2568
+ ObjectPath = Right(ObjectPath, Len(ObjectPath) - 1)
2569
+ End If
2570
+
2571
+ If Right(ObjectPath, 1) = "/" Then
2572
+ ObjectPath = Left(ObjectPath, Len(ObjectPath) - 1)
2573
+ End If
2574
+
2575
+ If (Err.Number <> 0) Then
2576
+ ReportError ()
2577
+ WScript.Echo GetLocalizedResource("StrRes235") & ObjectPath
2578
+ WScript.Quit (Err.Number)
2579
+ End If
2580
+
2581
+ End Sub
2582
+
2583
+
2584
+ '''''''''''''''''''''''''''''
2585
+ ' AppCreateCommand
2586
+ '''''''''''''''''''''''''''''
2587
+ Function AppCreateCommand(InProcFlag)
2588
+ On Error Resume Next
2589
+
2590
+ Dim IIsObject
2591
+ Dim IIsObjectPath
2592
+ Dim ObjectPath
2593
+ Dim MachineName
2594
+
2595
+ AppCreateCommand = 0 ' Assume Success
2596
+
2597
+ If ArgCount <> 2 Then
2598
+ WScript.Echo GetLocalizedResource("StrRes236")
2599
+ WScript.Quit (GENERAL_FAILURE)
2600
+ End If
2601
+
2602
+ ObjectPath = Args(1)
2603
+ SanitizePath ObjectPath
2604
+ MachineName = SeparateMachineName(ObjectPath)
2605
+
2606
+ IIsObjectPath = "IIS://" & MachineName
2607
+ If ObjectPath <> "" Then
2608
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2609
+ End If
2610
+
2611
+ Set IIsObject = GetObject(IIsObjectPath)
2612
+
2613
+ If (Err.Number <> 0) Then
2614
+ ReportError ()
2615
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2616
+ WScript.Quit (Err.Number)
2617
+ End If
2618
+
2619
+ IIsObject.AppCreate2 (InProcFlag)
2620
+
2621
+ If (Err.Number <> 0) Then
2622
+ ReportError ()
2623
+ WScript.Echo GetLocalizedResource("StrRes238") & ObjectPath
2624
+ WScript.Quit (Err.Number)
2625
+ End If
2626
+
2627
+ WScript.Echo GetLocalizedResource("StrRes239")
2628
+
2629
+ End Function
2630
+
2631
+
2632
+ '''''''''''''''''''''''''''''
2633
+ ' AppDeleteCommand
2634
+ '''''''''''''''''''''''''''''
2635
+ Function AppDeleteCommand()
2636
+ On Error Resume Next
2637
+
2638
+ Dim IIsObject
2639
+ Dim IIsObjectPath
2640
+ Dim ObjectPath
2641
+ Dim MachineName
2642
+
2643
+ AppDeleteCommand = 0 ' Assume Success
2644
+
2645
+ If ArgCount <> 2 Then
2646
+ WScript.Echo GetLocalizedResource("StrRes240")
2647
+ WScript.Quit (GENERAL_FAILURE)
2648
+ End If
2649
+
2650
+ ObjectPath = Args(1)
2651
+ SanitizePath ObjectPath
2652
+ MachineName = SeparateMachineName(ObjectPath)
2653
+
2654
+ IIsObjectPath = "IIS://" & MachineName
2655
+ If ObjectPath <> "" Then
2656
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2657
+ End If
2658
+
2659
+ Set IIsObject = GetObject(IIsObjectPath)
2660
+
2661
+ If (Err.Number <> 0) Then
2662
+ ReportError ()
2663
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2664
+ WScript.Quit (Err.Number)
2665
+ End If
2666
+
2667
+ IIsObject.AppDelete
2668
+
2669
+ If (Err.Number <> 0) Then
2670
+ ReportError ()
2671
+ WScript.Echo GetLocalizedResource("StrRes242") & ObjectPath
2672
+ WScript.Quit (Err.Number)
2673
+ End If
2674
+
2675
+ WScript.Echo GetLocalizedResource("StrRes243")
2676
+
2677
+ End Function
2678
+
2679
+
2680
+ '''''''''''''''''''''''''''''
2681
+ ' AppUnloadCommand
2682
+ '''''''''''''''''''''''''''''
2683
+ Function AppUnloadCommand()
2684
+ On Error Resume Next
2685
+
2686
+ Dim IIsObject
2687
+ Dim IIsObjectPath
2688
+ Dim ObjectPath
2689
+ Dim MachineName
2690
+
2691
+ AppUnloadCommand = 0 ' Assume Success
2692
+
2693
+ If ArgCount <> 2 Then
2694
+ WScript.Echo GetLocalizedResource("StrRes244")
2695
+ WScript.Quit (GENERAL_FAILURE)
2696
+ End If
2697
+
2698
+ ObjectPath = Args(1)
2699
+ SanitizePath ObjectPath
2700
+ MachineName = SeparateMachineName(ObjectPath)
2701
+
2702
+ IIsObjectPath = "IIS://" & MachineName
2703
+ If ObjectPath <> "" Then
2704
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2705
+ End If
2706
+
2707
+ Set IIsObject = GetObject(IIsObjectPath)
2708
+
2709
+ If (Err.Number <> 0) Then
2710
+ ReportError ()
2711
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2712
+ WScript.Quit (Err.Number)
2713
+ End If
2714
+
2715
+ IIsObject.AppUnload
2716
+
2717
+ If (Err.Number <> 0) Then
2718
+ ReportError ()
2719
+ WScript.Echo GetLocalizedResource("StrRes246") & ObjectPath
2720
+ WScript.Quit (Err.Number)
2721
+ End If
2722
+
2723
+ WScript.Echo GetLocalizedResource("StrRes247")
2724
+
2725
+ End Function
2726
+
2727
+
2728
+ Function AppDisableCommand()
2729
+ On Error Resume Next
2730
+
2731
+ Dim IIsObject
2732
+ Dim IIsObjectPath
2733
+ Dim ObjectPath
2734
+ Dim MachineName
2735
+
2736
+ AppDisableCommand = 0 ' Assume Success
2737
+
2738
+ If ArgCount <> 2 Then
2739
+ WScript.Echo GetLocalizedResource("StrRes248")
2740
+ WScript.Quit (GENERAL_FAILURE)
2741
+ End If
2742
+
2743
+ ObjectPath = Args(1)
2744
+ SanitizePath ObjectPath
2745
+ MachineName = SeparateMachineName(ObjectPath)
2746
+
2747
+ 'debug
2748
+ 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
2749
+
2750
+ IIsObjectPath = "IIS://" & MachineName
2751
+ If ObjectPath <> "" Then
2752
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2753
+ End If
2754
+
2755
+ Set IIsObject = GetObject(IIsObjectPath)
2756
+
2757
+ If (Err.Number <> 0) Then
2758
+ ReportError ()
2759
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2760
+ WScript.Quit (Err.Number)
2761
+ End If
2762
+
2763
+ IIsObject.AppDisable
2764
+
2765
+ If (Err.Number <> 0) Then
2766
+ ReportError ()
2767
+ WScript.Echo GetLocalizedResource("StrRes251") & ObjectPath
2768
+ WScript.Quit (Err.Number)
2769
+ End If
2770
+
2771
+ 'debug
2772
+ 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
2773
+
2774
+ WScript.Echo GetLocalizedResource("StrRes253")
2775
+
2776
+ End Function
2777
+
2778
+ Function AppEnableCommand()
2779
+ On Error Resume Next
2780
+
2781
+ Dim IIsObject
2782
+ Dim IIsObjectPath
2783
+ Dim ObjectPath
2784
+ Dim MachineName
2785
+
2786
+ AppEnableCommand = 0 ' Assume Success
2787
+
2788
+ If ArgCount <> 2 Then
2789
+ WScript.Echo GetLocalizedResource("StrRes254")
2790
+ WScript.Quit (GENERAL_FAILURE)
2791
+ End If
2792
+
2793
+ ObjectPath = Args(1)
2794
+ SanitizePath ObjectPath
2795
+ MachineName = SeparateMachineName(ObjectPath)
2796
+
2797
+ 'debug
2798
+ 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
2799
+
2800
+ IIsObjectPath = "IIS://" & MachineName
2801
+ If ObjectPath <> "" Then
2802
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2803
+ End If
2804
+
2805
+ Set IIsObject = GetObject(IIsObjectPath)
2806
+
2807
+ If (Err.Number <> 0) Then
2808
+ ReportError ()
2809
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2810
+ WScript.Quit (Err.Number)
2811
+ End If
2812
+
2813
+ IIsObject.AppEnable
2814
+
2815
+ If (Err.Number <> 0) Then
2816
+ ReportError ()
2817
+ WScript.Echo GetLocalizedResource("StrRes257") & ObjectPath
2818
+ WScript.Quit (Err.Number)
2819
+ End If
2820
+
2821
+ 'debug
2822
+ 'WScript.Echo "Last Error: " & Err & " (" & Hex (Err) & "): " & Err.Description
2823
+
2824
+ WScript.Echo GetLocalizedResource("StrRes259")
2825
+
2826
+ End Function
2827
+
2828
+ '''''''''''''''''''''''''''''
2829
+ ' AppGetStatusCommand
2830
+ '''''''''''''''''''''''''''''
2831
+ Function AppGetStatusCommand()
2832
+ On Error Resume Next
2833
+
2834
+ Dim IIsObject
2835
+ Dim IIsObjectPath
2836
+ Dim ObjectPath
2837
+ Dim MachineName
2838
+ Dim Status
2839
+
2840
+ AppGetStatusCommand = 0 ' Assume Success
2841
+
2842
+ If ArgCount <> 2 Then
2843
+ WScript.Echo GetLocalizedResource("StrRes260")
2844
+ WScript.Quit (GENERAL_FAILURE)
2845
+ End If
2846
+
2847
+ ObjectPath = Args(1)
2848
+ SanitizePath ObjectPath
2849
+ MachineName = SeparateMachineName(ObjectPath)
2850
+
2851
+ IIsObjectPath = "IIS://" & MachineName
2852
+ If ObjectPath <> "" Then
2853
+ IIsObjectPath = IIsObjectPath & "/" & ObjectPath
2854
+ End If
2855
+
2856
+ Set IIsObject = GetObject(IIsObjectPath)
2857
+
2858
+ If (Err.Number <> 0) Then
2859
+ ReportError ()
2860
+ WScript.Echo GetLocalizedResource("StrRes237") & ObjectPath
2861
+ WScript.Quit (Err.Number)
2862
+ End If
2863
+
2864
+ Status = IIsObject.AppGetStatus2
2865
+
2866
+ If (Err.Number <> 0) Then
2867
+ ReportError ()
2868
+ WScript.Echo GetLocalizedResource("StrRes262") & ObjectPath
2869
+ WScript.Quit (Err.Number)
2870
+ End If
2871
+
2872
+ WScript.Echo GetLocalizedResource("StrRes263") & Status
2873
+
2874
+ End Function
2875
+
2876
+
2877
+
2878
+ ''''''''''''''''''''''''''
2879
+ '
2880
+ ' IsSecureProperty
2881
+ '
2882
+ ' Checks to see if the property requires special processing in order to
2883
+ ' display its contents.
2884
+ '
2885
+ ''''''''''''''''''''''''''
2886
+ Function IsSecureProperty(ObjectParameter,MachineName)
2887
+
2888
+ On Error Resume Next
2889
+ Dim PropObj,Attribute
2890
+ Set PropObj = GetObject("IIS://" & MachineName & "/schema/" & ObjectParameter)
2891
+ If (Err.Number <> 0) Then
2892
+ ReportError ()
2893
+ WScript.Echo GetLocalizedResource("StrRes264") & err.number
2894
+ WScript.Quit (Err.Number)
2895
+ End If
2896
+ Attribute = PropObj.Secure
2897
+ If (Attribute = True) Then
2898
+ IsSecureProperty = True
2899
+ Else
2900
+ IsSecureProperty = False
2901
+ End If
2902
+ End Function
2903
+
2904
+
2905
+ ' We want to be able to cope with 32-bit unsigned integers,
2906
+ ' but CLng works with 32-bit signed integers
2907
+ Function StringTo32BitUnsignedInteger(ValueData)
2908
+ Dim numVal
2909
+ If (UCase(Left(ValueData, 2))) = "0X" Then
2910
+ ValueData = "&h" & Right(ValueData, Len(ValueData) - 2)
2911
+ End If
2912
+
2913
+ numVal = Int(ValueData) ' Despite its name, this actually turns it into a double.
2914
+
2915
+ If numVal < 0 Or numVal >= 4294967296 Then
2916
+ ' this number is out of the range of a 32-bit unsigned integer,
2917
+ Err.Raise 6 ' overflow
2918
+ ElseIf numVal >= 2147483648 Then
2919
+ ' bias downwards by -2^32
2920
+ numVal = numVal - 4294967296
2921
+ End If
2922
+
2923
+ StringTo32BitUnsignedInteger = CLng(numVal)
2924
+ End Function
2925
+
2926
+
2927
+ Function UnsignedIntegerToString(ValueData)
2928
+ Dim numVal
2929
+
2930
+ numVal = CLng(ValueData)
2931
+ numVal = Int(numVal)
2932
+
2933
+ If numVal < 0 Then
2934
+ numVal = numVal + 4294967296
2935
+ End If
2936
+
2937
+ UnsignedIntegerToString = CStr(numVal)
2938
+ End Function