473,507 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to WMI on a Remote Computer using C#

13 New Member
Hi,
I am Connecting ti remote computer using C# WMI through the following code.But i t gives Some error "INVALID PARAMETERS" plse suggest me any modification in the code.
Expand|Select|Wrap|Line Numbers
  1. try
  2.             {
  3.                 ConnectionOptions connection = new ConnectionOptions();
  4.                 connection.Username = userNameBox.Text;
  5.                 connection.Password = passwordBox.Text;
  6.                 connection.Authority = "ntlmdomain:DOMAIN";
  7.  
  8.                 ManagementScope scope = new ManagementScope(
  9.                     "\\\\FullComputerName\\root\\CIMV2", connection);
  10.                 scope.Connect();
  11.  
  12.                 ObjectQuery query= new ObjectQuery(
  13.                     "SELECT * FROM Win32_Service"); 
  14.  
  15.                 ManagementObjectSearcher searcher = 
  16.                     new ManagementObjectSearcher(scope, query);
  17.  
  18.                 foreach (ManagementObject queryObj in searcher.Get())
  19.                 {
  20.                     Console.WriteLine("-----------------------------------");
  21.                     Console.WriteLine("Win32_Service instance");
  22.                     Console.WriteLine("-----------------------------------");
  23.                     Console.WriteLine("Caption: {0}", queryObj["Caption"]);
  24.                     Console.WriteLine("Description: {0}", queryObj["Description"]);
  25.                     Console.WriteLine("Name: {0}", queryObj["Name"]);
  26.                     Console.WriteLine("PathName: {0}", queryObj["PathName"]);
  27.                     Console.WriteLine("State: {0}", queryObj["State"]);
  28.                     Console.WriteLine("Status: {0}", queryObj["Status"]);
  29.                 }
  30.                 Close();
  31.             }
  32.             catch(ManagementException err)
  33.             {
  34.                 MessageBox.Show("An error occured while querying for WMI data: "
  35.                     + err.Message);
  36.             }
Thanks
Prasad
Dec 8 '08 #1
1 23915
PRR
750 Recognized Expert Contributor
Connect To remote PC
There are certain issues regarding WMI connection to remote Pcs ...
Issues
Also a firewall may block remote WMI calls...
Also check this thread wmi
Dec 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3227
by: stabbert | last post by:
We are running DB2 UDB 8.1.6 in a partitioned environment where we have 8 physical nodes. We have a process that remotely connects to each individual node and loads some data. By setting the...
1
2596
by: Jim Bayers | last post by:
Our network nazi doesn't want us running a webserver on the server that has a connection to the campus database so we created a remote object that runs as a windows service. The windows service...
3
1448
by: Frank Schumacher | last post by:
Hi NG, I try to connect to a remote MS-SQL-Server 2000 from an ASP.NET application. Here's how I do it: private void ConnectToDatabase(string host, string dataBaseName, string userID, string...
9
2687
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
0
3902
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
0
1470
by: Zebadunc | last post by:
I have a vb.net form that lists the shared printers in from a remote computer in a checklist box giving the shareName as the value for the user to select. I want to use the print server name and...
1
1639
by: SayamiSuchi | last post by:
Hi.. I have been assigned to make a database in some remote machine.The machine has MSSQL 2005.I need to connect to that remote machine's sql server via my pc using my SQL Management express.I do...
2
1849
by: SayamiSuchi | last post by:
-------------------------------------------------------------------------------- Hi, I have made one web application using Asp dot net 2005 and sql server 2005.The sql server i am connecting is...
3
5725
by: Me LK | last post by:
I did a search but could not find an aswer that worked so here it goes. I just did an upgrade from 2003 to vs 2005 express. I am using a remote sql server 2000. I specifically upgrade to make...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.