Using Scripter object |
Scripter object can be used for faster execution of multiple remote management operations.
How to use:
Create text file "ScripterCode.txt" with code:
'================== START ===============
'This sub creates 10 new rules
Sub Create_10_Rules
Dim I
For I = 1 To 10
TrafficFilter.Rules.Insert 0, "MyNewRule" & I
Next
End Sub
'=================== END ================
Create file "TestScripter.vbs" with code:
'================== START ===============
Const SNetComRemote = "NetCom.Remote"
Dim Scripter, Remote, Root
'Loads text file
Function ReadText(AFileName)
Set F = CreateObject("Scripting.FileSystemObject").OpenTextFile(AFileName, 1)
ReadText = F.ReadAll
F.Close
End Function
Set Remote = CreateObject(SNetComRemote)
With Remote
.Host = "127.0.0.1"
.UserName = "Administrator"
.Password = "MyPassword"
Set Root = .CreateRoot
End With
With Root
Set Scripter = .CreateScripter
Scripter.AddCode ReadText("ScripterCode.txt")
Scripter.AsObject.Create_10_Rules
End With
Set Scripter = Nothing
Set Root = Nothing
Set Remote = Nothing
'=================== END ================
Put these two files to the same directory and run TestScripter.vbs like this:
"cscript.exe TestScripter.vbs"