Forum Discussion

teemu_selkala's avatar
teemu_selkala
Occasional Contributor
13 years ago

Wscript Shell - launch issue

If I would do windows - run... and execute there ftp I get command window normally where I can input commands.



While I execute following code trying to achieve same window appears but it never gets the command line to input commands but remains indefinately as a window without input option. any idea why or how to bypass this issue?




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



executeCommand = WshShell.Exec("ftp")



Thanks :)


  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Teemu,


     


    As the ftp command doesn't have GUI, you'd better use the following approach:


    function Test()


    {


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


      executeCommand = WshShell.Run("cmd");


      if (Sys.WaitProcess("cmd", 3000).Exists)


      {


        Sys.Process("cmd").Window("ConsoleWindowClass", "*", 1).Keys("ftp[Enter]")


        Sys.Process("cmd").Window("ConsoleWindowClass", "*", 1).Keys("?")


      }


    }


     


    Read the "Testing Console Applications" article for details.