' +----------------------------------------------------------------------------+ ' | Jeffrey M. Hunter | ' | jhunter@idevelopment.info | ' | www.idevelopment.info | ' |----------------------------------------------------------------------------| ' | Copyright (c) 1998-2011 Jeffrey M. Hunter. All rights reserved. | ' |----------------------------------------------------------------------------| ' | FILE : WhoAmI.vbs | ' | CLASS : Networking | ' | PURPOSE : Determine currently logged in user. | ' | PARAMETERS : None | ' | USAGE : cscript WhoAmI.vbs //NoLogo | ' | NOTE : As with any code, ensure to test this script in a development | ' | environment before attempting to run it in production. | ' +----------------------------------------------------------------------------+ Option Explicit Function Main Dim objNetwork Dim strCurrentUserName, strCurrentDomainName, strFullUserName Dim strComputerName Set objNetwork = WScript.CreateObject("WScript.Network") strCurrentUserName = objNetwork.UserName strCurrentDomainName = objNetwork.UserDomain strComputerName = objNetwork.ComputerName strFullUserName = strCurrentDomainName & "\\" & strCurrentUserName WScript.Echo "Current logged in user: " & strFullUserName & " on " & strComputerName & VbCrLf End Function Main WScript.Quit(0)