Pages

Wednesday, 19 October 2011

QTP Script: Get a value from a Windows System Variable


' for example to get the oracle home path
MsgBox GetSystemVariable("ORACLE_HOME")

' =============================================================
' function: GetSystemVariable
' desc : Get the value of a system variable
' params : strSysVar is the variable name
' returns : Content of variable name
' =============================================================
Function GetSystemVariable(strSysVar)

Dim objWshShellobjWshProcessEnv

' create the shell object
Set objWshShell = CreateObject("WScript.Shell")
Set objWshProcessEnv = objWshShell.Environment("Process")

' return the system variable content 
GetSystemVariable = objWshProcessEnv(strSysVar)

End Function ' GetSystemVariable

0 comments:

Post a Comment