Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - how to log output from a command line program

Reply
 
Old 04-19-2009   #1 (permalink)
Luka1993


 
 

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
Old 04-19-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: how to log output from a command line program


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

> 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
Old 04-19-2009   #3 (permalink)
mr_unreliable


 
 

Re: how to log output from a command line program

Luka1993 wrote:
Quote:

> 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
Old 04-19-2009   #4 (permalink)
Brock Hensley


 
 

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
Quote:

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
Send command line via WMI - Pipe output to text file on remote mac PowerShell
Re: Send command line via WMI - Pipe output to text file on remote PowerShell
Suppress output from a command line tool PowerShell
MS-DOS program starts only in full screen mode from command line Vista General
Output Event Log From Command Line Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46