Can anyone tell me the code to read a commandline output in a .HTA file.
To elaborate it further, let me give you an example. If I type "dir" on
command prompt, it returns the list of files and folders. What I want is
to pass "dir" command on the shell and get the output in a variable that I
wil fill in a textarea.
This "dir" is just an example of what I want, not the actual application.
My actual application is a commandline software that returns a value on
the command line.
To be more specific, I do not want to write the output to a text file.
Just get it back in a variable. Further, I am looking for a solution for a
.HTA file and not for .vbs file. I could not find a newsgroup for .hta so
am posting this message here.
Thanks in advance!
You might run the command under the control of a WshShellExec-object
which has access to stdout, stderr and stdin.
As for console-windows there is afaik no way to hide them using
WshShell.Exec.
MfG,
Alex
'if you only want to process *one* shell-cmd
'use cmd with the /c switch so it quits when work is done:
Set ws = CreateObject("WScript.Shell")
set cmd = ws.Exec("cmd /c cd /d C:\ & dir")
ws.popup cmd.stdout.readall 'get+show output
'if you want to process *multiple* shell-cmd
'use cmd with the /k switch, which opens it as a session.
'So you can exec shell-cmds be writing lines to stdin:
Set ws = CreateObject("WScript.Shell")
set cmd = ws.Exec("cmd /k")
cmd.stdin.writeline("cd /d %windir%") 'nav to windir
cmd.stdin.writeline("dir") 'list files
cmd.stdin.writeline("cd \") 'nav to root
cmd.stdin.writeline("dir") 'list files
cmd.stdin.close 'close stdin [can't reopen!]
'-> sets EOF to stdout
ws.popup cmd.stdout.readall 'get+show output
Thanks again!
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
For a single file solution, see the the 8th post of the following
thread:
http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/54d3df2e29211bad/
Csaba