IIS設定VBスクリプト
IISのMAPSを設定するVBスクリプトを作成してみた。リスト型で複数設定できる。
ファイルを事前に作成しておく必要がある。こんな感じで。先頭行は仮想フォルダ名。
-
-
-
-
- -
-
-
-
W3SVC/1/Root/xxxx
.asax,C:\Windows\\xxxx\aspnet_isapi.dll,5,"GET,HEAD,POST"
.asmx,C:\Windows\\xxxx\aspnet_isapi.dll,5,"GET,HEAD,POST"
.config,C:\Windows\\xxxx\aspnet_isapi.dll,1,"GET,HEAD,POST"
-
-
-
-
- -
-
-
-
IISのCustomHeaderを設定するVBスクリプトを作成してみた。リスト型で複数設定できる。
Dim ArgObj ' Object which contains the command line argument
Dim Result ' Result of the command function call
Dim Args(10) ' Array that contains all of the non-global arguments
Dim ArgCount ' Tracks the size of the Args arrayReDim Maps(0)
Dim ObjectPath
Dim fName' Get the Arguments object
Set ArgObj = WScript.Arguments' Test to make sure there is at least one command line arg - the command
If ArgObj.Count < 1 Then
DisplayHelpMessage
WScript.Quit (GENERAL_FAILURE)
End IfDim I
For I = 0 To ArgObj.Count - 1
Args(ArgCount) = ArgObj.Item(I)
ArgCount = ArgCount + 1
NextfName = Args(0)
Const ForReading = 1
Const TristateFalse = 0
Dim retstring
Dim fs, f
Dim iLine
iLine = 0Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(fName) <> True then
WScript.Echo fName & " File not Found"
WScript.Quit ()
End If
Set f = fs.OpenTextFile(fName, ForReading, TristateFalse)
Do While f.AtEndOfStream <> True
iLine = iLine + 1
retstring = f.ReadLine
If iLine = 1 then
ObjectPath = retstring
Else
ReDim Preserve Maps(iLine - 2)
Maps(iLine - 2) = retstring
End If
Loop
f.CloseSet IIsWebAppObj = GetObject("IIS://localhost/" & ObjectPath)
'全部削除する
IIsWebAppObj.PutEx 1, "ScriptMaps", True
'Mapsを設定
IIsWebAppObj.PutEx 2, "ScriptMaps", MapsIIsWebAppObj.SetInfo
WScript.Quit ()
Sub DisplayHelpMessage()
WScript.Echo " IISMap_ADSI.vbs"
WScript.Echo " "
WScript.Echo " "
WScript.Echo " \t Syntax:"
WScript.Echo " IISMap.js"
WScript.Echo " "
WScript.Echo " \t Example:"
WScript.Echo " Cscript /nologo IISMap_ADSI.js c:\\mymaps.txt"
WScript.Echo " "
WScript.Echo " \t Syntax of File:"
WScript.Echo ""
WScript.Echo "End Sub
ファイルを事前に作成しておく必要がある。こんな感じで。先頭行は仮想フォルダ名。
-
-
-
- -
-
-
W3SVC/1/Root/xxxx
X-Powered-By:ASP.NET
Cache-Control:private
-
-
-
- -
-
-
Dim ArgObj ' Object which contains the command line argument
Dim Result ' Result of the command function call
Dim Args(10) ' Array that contains all of the non-global arguments
Dim ArgCount ' Tracks the size of the Args arrayReDim Maps(0)
Dim ObjectPath
Dim fName' Get the Arguments object
Set ArgObj = WScript.Arguments' Test to make sure there is at least one command line arg - the command
If ArgObj.Count < 1 Then
DisplayHelpMessage
WScript.Quit (GENERAL_FAILURE)
End IfDim I
For I = 0 To ArgObj.Count - 1
Args(ArgCount) = ArgObj.Item(I)
ArgCount = ArgCount + 1
NextfName = Args(0)
Const ForReading = 1
Const TristateFalse = 0
Dim retstring
Dim fs, f
Dim iLine
iLine = 0Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(fName) <> True then
WScript.Echo fName & " File not Found"
WScript.Quit ()
End If
Set f = fs.OpenTextFile(fName, ForReading, TristateFalse)
Do While f.AtEndOfStream <> True
iLine = iLine + 1
retstring = f.ReadLine
If iLine = 1 then
ObjectPath = retstring
Else
ReDim Preserve Maps(iLine - 2)
Maps(iLine - 2) = retstring
End If
Loop
f.CloseSet IIsWebAppObj = GetObject("IIS://localhost/" & ObjectPath)
'全部削除する
IIsWebAppObj.PutEx 1, "HttpCustomHeaders", True
'Mapsを設定
IIsWebAppObj.PutEx 2, "HttpCustomHeaders", MapsIIsWebAppObj.SetInfo
WScript.Quit ()
Sub DisplayHelpMessage()
WScript.Echo " IISMap_ADSI.vbs"
WScript.Echo " "
WScript.Echo " "
WScript.Echo " \t Syntax:"
WScript.Echo " IISMap.js"
WScript.Echo " "
WScript.Echo " \t Example:"
WScript.Echo " Cscript /nologo CusHead_ADSI.js c:\\myhead.txt"
WScript.Echo " "
WScript.Echo " \t Syntax of File:"
WScript.Echo ""
WScript.Echo "End Sub