Google News
logo
QTP/UFT - Interview Questions
What are the ways in UFT to get system environment variables in UFT?
There are three ways to get system environment variables in UFT
 
Use the WSH shell object
 
* Use WMI’s Win32_Environment Class
* Read variables from the registry
Set myShell = CreateObject (“WScript.Shell”)

WScript.Echo myShell.ExpandEnvironmentStrings( "%PATHEXT%" )

myShell=Nothing,​
Output : .BAT;.CMD;.VBS;. VBE;. JS;. JSE
 
Other user variable, like TEMP, overwrite their system counterpart
Set myShell = CreateObject( "WScript.Shell" )

WScript.Echo myShell.ExpandEnvironmentStrings( "TEMP=%TEMP%" )

myShell=Nothing
Output : TEMP:C:\DOCUME~1\You\LOCALS~1\Temp
Advertisement