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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find out your Computername using the Windows Scripting Host

Networks

Find out your Computername using the Windows Scripting Host

by  Painkiller  Posted    (Edited  )
Using the windows scripting host, you can not only find out the name of your computer, but also your login name and the domain with which you logged on (of course, this info was actually meant to be used for VBscript to use in ASP pages, but I like to use this in VB anyway).

In your project, add a reference to the Windows Scripting Host Object Model. Add 3 textboxes and a commandbutton to your form.

use the following code:

Private Sub Command1_Click()

Dim objWSH As IWshNetwork

Set objWSH = New IWshNetwork_Class

Text1.Text = objWSH.ComputerName
Text2.Text = objWSH.UserName
Text3.Text = objWSH.UserDomain

End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top