Forum Discussion

saurabh1484's avatar
saurabh1484
Contributor
13 years ago

How to launch application without using Testesapps

Hi,



I want to start the notepad application without using the code "TestedApps.notepad.run()"

Assume that i know my application path and want to start thru code something [ExeLoc].Run() etc.

Any help?



regards,

Saurabh

6 Replies


  • Hi Christophe,



    I suspect that you get this message as the path to your executable file is specified incorrectly. Please pay attention to that all of the files specified to be opened in the command line must be referenced using the full path to the file. If the file path contains spaces, it should be enclosed in quotes (""). Also please note that you can use the GetEnvironmentVariable method to get the ProgramFiles environment variable.



    Look at the example:





    Sub OpenTestApplication

      Dim WshShell

      Set WshShell = Sys.OleObject("WScript.Shell") 

      command = """" & aqEnvironment.GetEnvironmentVariable("ProgramFiles") & "\MyApp\app.exe"""  

      Log.Message command

      Call WshShell.Run(command)

    End Sub





    If this does not help, please post here the problematic code.
  • Hi Saurabh,



    You can use the Run and Exec methods of the WScript.Shell object.



    The following code demonstrates how to launch Notepad using the Run method:


    function RunNotepad()


    {


        var path;

        path = '"C:\\Windows\\Notepad.exe"';  

        WS = new ActiveXObject("WScript.shell");

        WS.Run(path);

        Log.Message("Notepad is running");  

    }





    I hope this helps.
  • DevChaminda's avatar
    DevChaminda
    Occasional Contributor
    Hi Lexi,



    Can I have the VB scripts of this please, I tried but no luck so far. 
  • DevChaminda's avatar
    DevChaminda
    Occasional Contributor
    I slove the issue following is the VB scripts sample , this open the test application which on given file location.

    Sub OpenTestApplication


    Dim WshShell, WshShellExec

    ' Open test application 

    Set WshShell = Sys.OleObject("WScript.Shell")

    Set WshShellExec = WshShell.Exec("C:\MyApp\bin\TestApp.exe")

    End Sub
  • Hi to all,

    I try to apply the proposed solution to my tests but I have a problem working with the "Program Files" directory.

    When I try with C:\\Windows\\Notepad.exe, it works, but when I try with C:\\Program Files\\MyApp\\app.exe it fails with the following JScript runtime error message : "The system cannot find the file specified".

    If I previously test the path with aqFileSystem.Exists(path), the result is True.

    I guess the issue is the space in the folder name, how may I solve this ?



    Thank you for help,

    Best,

    Christophe
  • Hi David,

    It works now with " surrounding.



    Thanks for your help.

    Christophe