How To Get Desktop Path Dynamically In QTP

September 24, 2013

In my initial days with QTP, frequently I needed to download somefile to upload or download from or to the desktop.
To be in safe side I always used a Environment variable which carried the value of the Desktop path.
Like --Environment("Desktop").value= "path of the machine"

So in every release I use to tag this script as needs update during rerun in different machine.

Later I found a nice solution to find out the desktop path dynamically.

Set WSHShell = CreateObject("WScript.Shell")
strShortcutLoc = WSHShell.SpecialFolders("Desktop")

This is a Tested code which can be used to any machine. My problem resolved.

You Might Also Like