Pages

Tuesday, September 10

How to get system/user name of machine in QTP/VBscript

Hello Friends!

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()

3 comments:

  1. Dim oNet, sUser
    Set oNet = CreateObject("WScript.Network")
    sUser = oNet.UserName
    loginUser = UCase(sUser)

    ReplyDelete
  2. Amazing blog it is. I love reading blogs. I do not excite constantly by way of reading blog posts. But on your blog I in finding something that suggests in blogging. Anyway, you’re unquestionably an excellent blogger and you have got a talent to make your reader to hold reading your blog post again and again. Keep it up the very good work. Proceed moving the persons! This is likely one of the very exciting post. Due to the fact I’m new in blogging and that I require great educational pastime like your post.
    Visit: Best essay writing service

    ReplyDelete
  3. Thanks for sharing amazing information !!!!!!
    Please keep up sharing.

    ReplyDelete