Poida
6 years agoOccasional Contributor
Testing Destination of Windows Shortcut lnk in Start Menu Win7x64
Hi,
I'm trying to get this JScript from https://support.smartbear.com/viewarticle/8967/ working in TestComplete 12.6 on Win7x64.
It's to verify the target value of the shortcut (what it's...
- 6 years ago
Thanks for the tips Robert. This is what I ended up with in case anyone else is looking for this later, in javascript
function Test_SCExists_GetSCPath() { if (!IsShortcutValid("Programs|Accessories|Paint", "|")) { Log.Error("Shortcut is not valid"); return; } Log.Message("Shortcut is valid"); var target = GetShortcutTarget("Programs|Accessories|Paint", "|"); if (!target) { Log.Error("Shortcut doesn't exist"); return; } Log.Message(target); } function IsShortcutValid(shortcutPath, separator) { var StartDir, path, shortcut; StartDir = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\"; path = shortcutPath.split(separator).join("\\") + ".lnk"; if (aqFileSystem.Exists(StartDir + path)) { shortcut = WshShell.CreateShortcut(StartDir + path); return aqFileSystem.Exists(shortcut.TargetPath); } return false; } function GetShortcutTarget(shortcutPath, separator) { var StartDir, path, shortcut; StartDir = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\"; path = shortcutPath.split(separator).join("\\") + ".lnk"; if (aqFileSystem.Exists(StartDir + path)) { shortcut = WshShell.CreateShortcut(StartDir + path); return shortcut.TargetPath; } return false; }