Win32_TerminalServiceSetting InvokeMethod Error VB.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All

I'm trying to get the Win32_TerminalServiceSetting InvokeMethod to work, but got the following error

An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dl
Additional information: Invalid method Parameter(s)

Some Code

Imports System.Managemen
Module Module
Sub Main(
Dim Options As New ConnectionOption
With Option
.Username = "Domain\Username" 'Domain\Use
.Password = "Password" ' Passwor
End Wit

Dim Path As New ManagementPat
With Pat
.Server = "ServerName" 'Serve
.NamespacePath = "root\cimv2
.ClassName = "Win32_TerminalServiceSetting
End Wit

Dim Scope As New ManagementScop
With Scop
.Path = Pat
.Options = Option
End Wit

Tr
Scope.Connect(
Catch ex As Exceptio
Console.WriteLine("Error: " & ex.Message
End Tr

Dim Query As New ObjectQuer
With Quer
.QueryLanguage = "WQL
.QueryString = "Select AllowTSConnections from Win32_TerminalServiceSetting
End Wit

Dim TerminalServiceSettingClass As New ManagementClass(Scope, Path, Nothing
Dim InArgs As ManagementBaseObject = TerminalServiceSettingClass.GetMethodParameters("SetAllowTSConnections"
InArgs("AllowTSConnections") = 0 'or

Tr
Dim OutputArgs As ManagementBaseObject = TerminalServiceSettingClass.InvokeMethod("SetAllowTSConnections", InArgs, Nothing
'An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dl
'Additional information: Invalid method Parameter(s)

Console.WriteLine("Output: " & OutputArgs("Returnvalue")
Catch ex As Exceptio
Console.WriteLine("Error: " & ex.Message
End Tr
End Su
End Modul

Thanks in advanc

Jesper Hanno
 
Back
Top