Javascript 如何通过TestComplete中的快捷方式验证应用程序是否成功启动?

Javascript 如何通过TestComplete中的快捷方式验证应用程序是否成功启动?,javascript,testcomplete,Javascript,Testcomplete,我试图通过TestComplete中的桌面快捷方式启动应用程序。我需要验证应用程序是否成功启动,如果没有,我想知道失败的原因 Testcomplete有助于使用Win32 API库调用某些Windows API。因此,为了通过exe启动应用程序,我使用Win32API.WinExec()方法。根据的返回值,我将知道是否有任何错误。但是WinExec不能与.lnk文件/快捷方式一起使用。一种替代方法是,我可以给出cmd/c xyz.lnk,它始终返回true,而不是将.lnk文件作为WinExec

我试图通过TestComplete中的桌面快捷方式启动应用程序。我需要验证应用程序是否成功启动,如果没有,我想知道失败的原因

Testcomplete有助于使用Win32 API库调用某些Windows API。因此,为了通过exe启动应用程序,我使用Win32API.WinExec()方法。根据的返回值,我将知道是否有任何错误。但是WinExec不能与.lnk文件/快捷方式一起使用。一种替代方法是,我可以给出cmd/c xyz.lnk,它始终返回true,而不是将.lnk文件作为WinExec的第一个参数,即使.lnk文件不存在,因为它在cmd.exe上验证是否成功。但是有没有更好的方法来验证这个场景呢


顺便说一句,我正在Testcomplete中使用JScript。

我已经基于这个How To条目创建了以下脚本:

以下是一个例子:

// One possible approach
function Test()
{
  var strShortcut = "D:\\Notepad.lnk";

  // Run the shortcut
  Sys.OleObject("WScript.Shell").Run(strShortcut);

  // Get the executable file name
  var targetFileName = GetShortcutTaget(strShortcut);
  if ("" == targetFileName)
  {
    Runner.Halt("The target file does not exist");
  }

  // Try to find a process with the executable name used in the shortcut
  var foundProc = Sys.FindChild("Path", targetFileName)

  // Process the result
  if (foundProc.Exists)
    Log.Message("The applicated started successfully: " + targetFileName);
  else
    Log.Warning("The applicated did not start: " + targetFileName);
}

function GetShortcutTaget(shortcutFileName)
{
  var WshShell = new ActiveXObject("WScript.Shell");
  var fso = new ActiveXObject("Scripting.FileSystemObject");

  if (fso.FileExists(shortcutFileName)) {
    var shortcut = WshShell.CreateShortcut(shortcutFileName);
    return shortcut.TargetPath;
  }

  return "";
}

您真的需要使用快捷方式启动应用程序吗?用TestedApps代替怎么样?这应该更容易。