Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Question

Status
Not open for further replies.
Jul 13, 2004
427
US
Hey all,

I'm trying to set the Terminal connection options via WMI in C# with the following code and failing with a "Not Found" error on my inParams object. Anyone have any thoughts as to what i'm doing wrong?

string RDP = "RDP-Tcp";
ManagementScope scope = new ManagementScope("\\\\" + tbComputerName.Text + "\\root\\cimv2");
ManagementPath path = new ManagementPath("Win32_TSClientSetting.TerminalName='" + RDP + "'");
ManagementObject obj = new ManagementObject(scope, path, null);
inParams = obj.GetMethodParameters("SetClientProperty");

inParams["clipboardmapping"] = 1;
inParams["DriveMapping"] = 1;
ManagementBaseObject outParams = obj.InvokeMethod("SetClientProperty", inParams, null);

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
To follow up on this... the following code works, but i'm looking for the C# Equivilent:

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")


Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
objItem.ConnectionPolicy = 0 'ENABLES Connection Override
objItem.Put_
errResult = objItem.ConnectionSettings(0,0,0) 'DISABLES Drive, Printer, Default Printer (as per order)

objItem.SetColorDepthPolicy(0) 'ENABLES Connection Override
objItem.Put_
objItem.SetColorDepth(3) 'SETS Color Depth to 16Bit (1=8Bit,2=15Bit,3=16Bit,4=32Bit)

errResult = objItem.SetClientProperty("AudioMapping", 1) 'DISABLES Audio
errResult = objItem.SetClientProperty("COMPortMapping", 1) 'DISABLES COM
errResult = objItem.SetClientProperty("LPTPortMapping", 0) 'ALLOWS LPT
errResult = objItem.SetClientProperty("ClipboardMapping", 0) 'ALLOWS Clipboard
errResult = objItem.SetClientProperty("WindowsPrinterMapping", 0) 'ALLOWS Windows Printers
errResult = objItem.SetClientProperty("DriveMapping", 1) 'DISABLES Drives
Next

~Intruder~
CEH, CISSP, MCSA/MCSE 2000/2003

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top