Sunday 2 February 2014

How to get User Name of the machine

Here in this post we will quickly see how to get the User Name of the machine you are executing your test. It's useful specially in results of your test. If you have have more then one users/machines involved in the test execution, it'll help you to differentiate which tests have been executed on which machine..  

Function f_GetSystemUserName()
    Set oSystemInfo = CreateObject("ADSystemInfo") 
    Set oUser=GetObject("LDAP://" & oSystemInfo.UserName)
    f_GetSystemUserName= oUser.DisplayName
    Set oSystemInfo = Nothing
    Set oUser = Nothing
End Function    'End of function f_GetSystemUserName()

'Calling above function 
Msgbox f_GetSystemUserName()

No comments:

Post a Comment