Results 1 to 4 of 4

Thread: Command Prompt

  1. #1

    Command Prompt

    we need to invoke the command prompt and run the command and then capture
    the result of command.Can you please suggest how to go about this

  2. #2

    Re: Command Prompt


    You can do this by using the Exec method of the WScript.Shell object:

    <font class="small">Code:</font><hr /><pre>//JScript
    var oExec = Sys.OleObject("WScript.Shell").Exec("cmd /c \"dir c:\\\"");
    var ret = oExec.StdOut.ReadAll();
    // ret contains the console output as a string
    ...</pre><hr />
    Jared - AQA Support

  3. #3

    Re: Command Prompt

    hi Jared

    Thanks for the reply.As we are using vb script i changed the code to:

    Set oExec = Sys.OleObject("WScript.Shell").Exec("cmd /c \"dir C:\abc\xyz"")
    ret = oExec.StdOut.ReadAll()

    but i am getting an error , is the format inside exe, i.e., the path format correct?

  4. #4

    Re: Command Prompt


    There's a syntax error in the method parameter (you need to double quotes inside string constants). Here's the correct syntax:
    <font class="small">Code:</font><hr /><pre>
    Set oExec = Sys.OleObject("WScript.Shell").Exec("cmd /c ""dir C:\abc\xyz""")
    ret = oExec.StdOut.ReadAll
    </pre><hr />
    Jared - AQA Support



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:33 PM.

Copyright BetaSoft Inc.