Check if the shortcut exists or Not? - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: Check if the shortcut exists or Not? (/Thread-Check-if-the-shortcut-exists-or-Not) |
Check if the shortcut exists or Not? - pjavvaru - 06-17-2010 I have two shortcuts for an application in a folder. note:They are not files but SHORTCUTS. I want to know if these shortcuts exists or not. i dont know but i used fso.fileexists which it doesnot take at all. when i look at the properties window of this shortcut it showed. type- application how can i find out if the shortcuts exists in a particular folder. This could sound silly but i really dont know. Thank you for your help. RE: Check if the shortcut exists or Not? - Saket - 06-17-2010 All you need to do is - write a WMI query that includes the path of the folder you want to check as well as the file extension for shortcuts i.e 'lnk' e.g this script checks if Quick Test Professional shortcut exist in folder "C:\Test\Shortcuts" Code: strComputer = "." RE: Check if the shortcut exists or Not? - pjavvaru - 06-17-2010 thank u saket. But can you explain me. I did not understand. Moreover i want to let you know. my application shows type of file: Application target: ending with some switch to the exe file. ex: aaa\xxx.exe\AUTOSAVE.. something like this now how will i be able to identify this thing? becoz i need to capture the text in the target and find out if it has some AUTOSAVE.. on it. thanks RE: Check if the shortcut exists or Not? - Saket - 06-17-2010 use objItem.Target to get the target and then search for the string you need to check. for explanation on WMI refer All About Windows Management Instrumentation (WMI) in QTP RE: Check if the shortcut exists or Not? - pjavvaru - 06-17-2010 I dont know for whatever reason. this shows invalid arguement or precedure error Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") I was searching a winzip shorcut which is in C:\Documents and Settings\All Users\Start Menu what could be the problem? RE: Check if the shortcut exists or Not? - Saket - 06-18-2010 try using special folder for start menu - Code: set objShell = createobject("Wscript.Shell") if you still face the issue, paste your code so that we can get a better idea. RE: Check if the shortcut exists or Not? - pjavvaru - 06-18-2010 hi Saket, i am still in confusion. This is my code. Let me know where i am going wrong. Code: Dim objItem, strComputer,objWMIService,ColItems it always shows General run error.. or something else sometimes.. on the Set objEMIService.. or else i get error @ for each line.. This is very important as i am stuck with work. moreover Start Menu is just a folder. what if there is a filefolder and in that a shortcut exists and i need to look for that shortcut? how can i find out. This there any other way to search and just need to confirm that the file exists. This is 1 small requirement to check if the shortcut exists. thanks RE: Check if the shortcut exists or Not? - Saket - 06-21-2010 This works fine at my side, but I doubt in your query. if you are searching in startmenu winzip shortcut must be in 'startmenu\programs\winzip' may be you can try replacing "." with the exact computer name, see if it works, I just noticed that we are going on a longer and bit complex raod, however it can be done in a very simple way. see the code below Code: Set objFSO1 = CreateObject("Scripting.FileSystemObject") let me know if this helps. |