473,397 Members | 1,961 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,397 software developers and data experts.

How do I get the user name in my VB.NET program?

I have written and Outlook Addin using VB.NET. How can I get the username of
the person logged in to the PC that the Addin is running on? Thanks.
Nov 21 '05 #1
3 1165
Lanem,

You can use WMI, however in my opinion is this snippet simpler for your
question using the Environment variable

\\\\needs 1 listbox on a form
Dim environmentVariables As IDictionary _
= Environment.GetEnvironmentVariables()
Dim de As DictionaryEntry
ListBox1.Items.Clear()
For Each de In environmentVariables
Me.ListBox1.Items.Add(de.Key.ToString & _
"=" & de.Value.ToString)
Next de
////
You see that a list from things in de.Key and de.Value. One of them is
username, however it is more interesting to look to all so I did not select
that.

Cor
Nov 21 '05 #2
In article <uU**************@TK2MSFTNGP10.phx.gbl>, Cor Ligthert wrote:
Lanem,

You can use WMI, however in my opinion is this snippet simpler for your
question using the Environment variable

\\\\needs 1 listbox on a form
Dim environmentVariables As IDictionary _
= Environment.GetEnvironmentVariables()
Dim de As DictionaryEntry
ListBox1.Items.Clear()
For Each de In environmentVariables
Me.ListBox1.Items.Add(de.Key.ToString & _
"=" & de.Value.ToString)
Next de
////
You see that a list from things in de.Key and de.Value. One of them is
username, however it is more interesting to look to all so I did not select
that.

Cor


Cor... Why not just use System.Environment.UserName?

Console.WriteLine (Environment.UserName)

--
Tom Shelton [MVP]
Nov 21 '05 #3
Tom,
Cor... Why not just use System.Environment.UserName?

Console.WriteLine (Environment.UserName)

Because I was lazy and just copied and pasted from a part of an older
program of me.
And thought with this is shown so much information, than he knows that as
well where to get that in an easy way as well.

However next time I do as you said.

:-)

Cor
Nov 21 '05 #4

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

Similar topics

11
by: Yasaswi Pulavarti | last post by:
I know there are some sample user exit programs in sqllib/samples/c directory. How do I tell DB2, which user exit program to use? I know I have to edit and compile the c based user exit programs,...
5
by: Bruno Mendonça | last post by:
My boss asked me to build a program to create a report with logon/logoff events for all users within our windows domain. I'm using .Net to do so and decided to have a program running on the Domain...
6
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
6
by: Juggler | last post by:
Hi all I've written a program in VB.NET that allows the user to build quotes for installing shower enclosures. As part of the program, I've included a blank Access database. I've provided them...
17
by: spentun | last post by:
How can I moitor file which is executed by user or program in window. I need to write a code to monitor file. When user clicks the file(.exe) or is called by program, the name of file will be...
1
by: Mircea | last post by:
Hi everybody, Sorry if this problem has been discussed, I did not find any useful information. I have one problem regarding C#. I want to run a program from a C# program as a different user....
2
by: niskin | last post by:
I'm trying to create a file called retrieve.vbs with my program and it creates this file, with all the necessary code for the file to run, but the part that relies on user input does not get written...
4
by: =?Utf-8?B?WmFyYm9yZw==?= | last post by:
I'm writing a little program that will run when a user logs in, checks their password expiration and also installs a piece of monitoring software if necessary. The program has to run on Vista so I...
82
by: happyse27 | last post by:
Hi All, I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters? Two codes below : a)...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
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
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
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
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
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
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
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
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.