Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

UserName Property

Returns the name of a user.

object.UserName 

Arguments

object
WshNetwork object.

Remarks

String.

If you are using this property in a login script, see Creating an Automated Login Script.

Example

The following example demonstrates the use of the UserName property:

<package>
   <job id="vbs">
      <script language="VBScript">
         Set WshNetwork = WScript.CreateObject("WScript.Network")
         WScript.Echo "Domain = " & WshNetwork.UserDomain
         WScript.Echo "Computer Name = " & WshNetwork.ComputerName
         WScript.Echo "User Name = " & WshNetwork.UserName
      </script>
   </job>

   <job id="js">
      <script language="JScript">
         var WshNetwork = WScript.CreateObject("WScript.Network");
         WScript.Echo("Domain = " + WshNetwork.UserDomain);
         WScript.Echo("Computer Name = " + WshNetwork.ComputerName);
         WScript.Echo("User Name = " + WshNetwork.UserName);
         }
      </script>
   </job>
</package>

See Also

Running Your Scripts

Applies To: WshNetwork Object

Show:
© 2015 Microsoft