Get Computer Name(VM Machine)
we run all our QTP scripts through VM machine , so i want to get that computer name (particular VM machine name) through qtp script
using environment variable alone we can achieve it or is there any other possible solution?
When Environment variable gives this, why do you want another way? Environment("LocalHostName")
thank you, i am running my scripts in VM machine...so only i hav this doubt, coz this is first time i am running my scripts in VM machine..
Environment("LocalHostName") ---> so this is enough?
' create a network object
Set objNet = CreateObject("WScript.NetWork")
' show the user name
MsgBox "User Name: " & objNet.UserName
' show the computer name
MsgBox "Computer Name: " & objNet.ComputerName
' show the domain name
MsgBox "Domain Name: " & objNet.UserDomain
' destroy the object
Set objNet = Nothing
the above code also gives the same code...can i try this as well?
There are different ways to do a task. You should take the simplest route. And that would be using the Environment variable in this case. The code you posted is also valid
hi Tarun ,
Thanks a lot for ur suggestions i will try with environment variable itself.
You can see all QTP Environmental variables names in the following path.
File -> Settings -> Choose "Environment" settings . There you can see built-in and user-defined environmental.
Choose built-in type, and you will see all QTP Environmental variables.