John Topley's Knowledgebase

Getting The User Name

Friday, 30 May 2003

This Windows Script Host script displays the name and domain of the currently logged on user.

Download GetUsername.vbs

' Script to get the domain and name of the logged on user.
Option Explicit
Private strDomain
Private strUserName
Private wshNetwork

Set wshNetwork = WScript.CreateObject("WScript.Network")

strDomain = wshNetwork.UserDomain
strUserName = wshNetwork.UserName

WScript.Echo "You are logged on as " & strDomain & "\" &
  strUserName & "."

Set wshNetwork = Nothing

top | index | no previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.