473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

using wmi to get username in remote machine

i have the following sub running on a small vb.net app,

Private Sub btnGetUserName_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles btnGetUserName.Click

Dim objWMIService As Management.ManagementObject
Dim strPath As String = "winmgmts:" & _
"{impersonationLevel=impersonate}\\" & txtComputerName.Text &
"\root\cimv2"

objWMIService = New Management.ManagementObject(strPath)

Dim colComputer As Management.ManagementQuery

'colComputer = New Management.SelectQuery("Select * from
Win32_ComputerSystem")
Dim selectQuery As New SelectQuery("Select * from
Win32_ComputerSystem")

Dim searcher As New ManagementObjectSearcher(selectQuery)

Dim mgmObject As ManagementObject
Dim strUserName As String
Dim strCompName As String

For Each mgmObject In searcher.Get()
strUserName = mgmObject("UserName").ToString()
strCompName = mgmObject("name").ToString

Next mgmObject

lblUserName.Text = strUserName
End Sub

when i try to run the program i get the following error:

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

Additional information: Invalid parameter

This error is refering to the line
objWMIService = New Management.ManagementObject(strPath)

it seems that my winmgmts syntax is not correct... but cant figure out what
is wrong with it. Any help would be much appreciated.

Thank you
Nov 21 '05 #1
0 3813

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
1
by: JJG | last post by:
Hello. I'm not sure if this is the right forum, so please let me know what is the correct one if it isn't. (I posted this one also to the win32.programmer.wmi forum). I've been puzzled by this...
10
by: Martin Robins | last post by:
I need to access the scheduler service on a network computer in order to manipulate it remotely from .NET; I have all of the necessary code to perform the manipulation and it works - great - but I am...
3
by: Carl | last post by:
Using VB .NET how can I enable my program to access a share on another machine and pass the user name and password. I have a computer and share, say "\\computer\share" so I can copy files from it...
5
by: Lambuz | last post by:
First of all, is it possible usign .NET remoting feature inside a .NET applet loaded into a tag object inside an HTML page ? <OBJECT id="myID" height="150" width="300"...
4
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
I have an application that runs fine on my machine(of course) that access the local Sql Server. However, when trying to run this application from another machine I receive a Sql timeout error. I...
1
by: remya1000 | last post by:
from my system i need to open a calculator in remote machine. and i'm using Vb.net and WMI. i need to pop up the calculator in remote machine, while i run one program in my system. while running in...
5
by: Matthew Wilson | last post by:
I wrote some code to create a user and update a user on a remote box by sending emails to that remote box. When I was done, I realized that my create_user function and my update_user function were...
0
vinoj
by: vinoj | last post by:
Hi All, These are the following things which i want to do:- 1. I will be taking the ipaddress, username and password from the user using cgi ffrom the browser. 2. Now i want...
1
by: thamayanthi | last post by:
Hi, Please find the below code which is used to Print the Operating System of a remote Machine of linux.This code is working fine,if i give the correct UserName and Password of a machine but what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.