Windows Vista Forums

how to log output from a command line program
  1. #1


    Luka1993 Guest

    how to log output from a command line program

    Hi!

    It is very simple to do it with batch
    for example:
    cmdprogram.exe > log.txt



    i tried it with vbscript but i dont know what im doing wrong....

    objShell.Run """" & sScriptPath & "\cmdprogram.exe" > "log.txt" & """", vbhide

      My System SpecsSystem Spec

  2. #2


    Richard Mueller [MVP] Guest

    Re: how to log output from a command line program


    "Luka1993" <Luka1993@xxxxxx> wrote in message
    news:0B171216-562C-4037-9276-F096917C7523@xxxxxx

    > Hi!
    >
    > It is very simple to do it with batch
    > for example:
    > cmdprogram.exe > log.txt
    >
    > i tried it with vbscript but i dont know what im doing wrong....
    >
    > objShell.Run """" & sScriptPath & "\cmdprogram.exe" > "log.txt" & """",
    > vbhide
    Try:

    ======
    strCmd = "%comspec% /c """ & sScriptPath & "\cmdprogram.exe"" > log.txt"
    objShell.Run strCmd, 0, True
    ======
    You can echo the value assigned to strCmd to make sure it looks correct. Any
    quotes embedded in a quoted string need to be doubled. If a string ends with
    a trailing quote, you get 3 quotes.

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  3. #3


    mr_unreliable Guest

    Re: how to log output from a command line program

    Luka1993 wrote:

    > i tried it with vbscript but i dont know what im doing wrong....
    >
    > objShell.Run """" & sScriptPath & "\cmdprogram.exe" > "log.txt" & """", vbhide
    hi Luka1993,

    Try this:

    oShell.Run """" & sScriptPath & "\cmdprogram.exe" & """" & " > log.txt"

    There is another suggestion, if you want to be a little
    more sophisticated. Read up on the WScript.Shell object's
    Exec Method, and how one would retrieve the StdOut property.

    The benefit of StdOut is that you can have the app's output
    coming back to your script either character-by-character,
    or line-by-line. This may or nay not be of value, but in
    some situations -- such as pinging another server -- it
    allows for taking some alternative logic path depending on
    the output, as it is occurring.

    cheers, jw
    ____________________________________________________________

    You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
    the answers will be applicable to the questions)


      My System SpecsSystem Spec

  4. #4


    Brock Hensley Guest

    Re: how to log output from a command line program

    Hello,

    Try this (the > is now inside of the quotes):

    objShell.Run """" & sScriptPath & "\cmdprogram.exe > log.txt" & """", vbhide

    Otherwise, are you getting any specific error message or just a syntax
    error?

    -B

    "Luka1993" <Luka1993@xxxxxx> wrote in message
    news:0B171216-562C-4037-9276-F096917C7523@xxxxxx

    > Hi!
    >
    > It is very simple to do it with batch
    > for example:
    > cmdprogram.exe > log.txt
    >
    > i tried it with vbscript but i dont know what im doing wrong....
    >
    > objShell.Run """" & sScriptPath & "\cmdprogram.exe" > "log.txt" & """",
    > vbhide

      My System SpecsSystem Spec

how to log output from a command line program problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send command line via WMI - Pipe output to text file on remote mac Ripp PowerShell 20 26 Sep 2008
Re: Send command line via WMI - Pipe output to text file on remote Shay Levy [MVP] PowerShell 0 26 Sep 2008
Suppress output from a command line tool Chris Harris PowerShell 6 23 May 2007
MS-DOS program starts only in full screen mode from command line =?Utf-8?B?SnVlcmdlbiBHYXU=?= Vista General 0 29 Aug 2006
Output Event Log From Command Line =?Utf-8?B?c2VucmFiZGV0?= Vista General 4 14 Aug 2006