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 - Batch file (CMD) output into HTA

Reply
 
Old 01-11-2009   #1 (permalink)
Daz


 
 

Batch file (CMD) output into HTA

Hi All,

I am wondering if it is possible to have output from a batch file back
into a HTA file.

What i want to do is use the nice features of HTA to put a nice clean
GUI on my batch files. So that instead of having the ugly command
text etc, i can have the output back into the HTA and then put some
clean type faces etc around it.

Is it possible? If so can someone provide and example of HTA code to
do it?

Any advice or help would be appreciated.

Cheers,
Daz

My System SpecsSystem Spec
Old 01-11-2009   #2 (permalink)
mayayana


 
 

Re: Batch file (CMD) output into HTA

Quote:

> What i want to do is use the nice features of HTA to put a nice clean
> GUI on my batch files. So that instead of having the ugly command
> text etc, i can have the output back into the HTA and then put some
> clean type faces etc around it.
>
That was really the whole point of script in the
first place -- to go beyond the simple DOS command
line in order to provide more options and GUI
possibilities. So if you want an HTA then why not use
the tool that goes with it? If you want to use DOS/batch
....aren't there groups for that? I just did a search of
MS newsgroups and only came up with this:

microsoft.public.win2000.cmdprompt.admin

I'm not sure what to search for other than "cmd".
There are no groups with "batch" in the name, and
not much in the way of groups with "dos" in the name.

In any case, this is a VBScript group.


My System SpecsSystem Spec
Old 01-11-2009   #3 (permalink)
Matthias Tacke


 
 

Re: Batch file (CMD) output into HTA

mayayana wrote:
Quote:
Quote:

>> What i want to do is use the nice features of HTA to put a nice clean
>> GUI on my batch files. So that instead of having the ugly command
>> text etc, i can have the output back into the HTA and then put some
>> clean type faces etc around it.
>>
>
> That was really the whole point of script in the
> first place -- to go beyond the simple DOS command
> line in order to provide more options and GUI
> possibilities. So if you want an HTA then why not use
> the tool that goes with it? If you want to use DOS/batch
> ...aren't there groups for that? I just did a search of
> MS newsgroups and only came up with this:
>
> microsoft.public.win2000.cmdprompt.admin
>
This group is ok, but hasn't much traffic recently.
Quote:

> I'm not sure what to search for other than "cmd".
> There are no groups with "batch" in the name, and
> not much in the way of groups with "dos" in the name.
>
What about the group: alt.msdos.batch.nt
Quote:

> In any case, this is a VBScript group.
>
His question addressed HTA, should be the proper group though.

It's a bit unclear what OP wants to nice up.

A good learning source might be scriptomaticv2. You have several
output options to choose from :
cmdline, text, html, xls

HTH
Matthias
My System SpecsSystem Spec
Old 01-11-2009   #4 (permalink)
mayayana


 
 

Re: Batch file (CMD) output into HTA

> What about the group: alt.msdos.batch.nt
Quote:

>
I'm surprised that MS doesn't seem to have more
relevant groups. DOS/batch isn't relevant here, yet
there seem to be a lot of people who are interested
in it. I would have thought that an admin group
might be best, but even with "admin" the selection
of Microsoft groups is sparse and specialized. I don't
see anything like:
microsoft.public.windows.admin[.scripting]

And the DOS groups seem to be only DOS. I guess
it would help if MS had come up with a name for the
expanded NT command line functionality, like DOS2,
NTDOS, or something like that.


My System SpecsSystem Spec
Old 01-11-2009   #5 (permalink)
Tom Lavedas


 
 

Re: Batch file (CMD) output into HTA

On Jan 11, 1:11*am, Daz <darren.black...@xxxxxx> wrote:
Quote:

> Hi All,
>
> I am wondering if it is possible to have output from a batch file back
> into a HTA file.
>
> What i want to do is use the nice features of HTA to put a nice clean
> GUI on my batch files. *So that instead of having the ugly command
> text etc, i can have the output back into the HTA and then put some
> clean type faces etc around it.
>
> Is it possible? *If so can someone provide and example of HTA code to
> do it?
>
> Any advice or help would be appreciated.
>
> Cheers,
> Daz
Here is an attempt I wrote some time back ...

<HTML>
<HEAD>
<TITLE> MSDOS Demo</TITLE>
<HTA:APPLICATION ID="oMSDOS" APPLICATIONNAME="MSDOSApp"
BORDER="thick" BORDERSTYLE="normal" CAPTION="yes"
ICON="C:\WinNT\system32\cmd.exe"
SINGLEINSTANCE="no" VERSION="1.0"
WINDOWSTATE="normal"/>

<SCRIPT Language=VBScript>
opener = "Me"

sub initialize
CurrentFolder.value = CreateObject("Wscript.Shell").CurrentDirectory
Cmd.focus
end sub

Function CmdPrompt(sCmd)
Dim alines, sCmdLine, stemp, ofs, oWS, nRes
'On Error Resume Next
sCmdLine = """%comspec%"" /c " & sCmd & " 1>> "
set ofs = CreateObject("Scripting.FileSystemObject")
stemp = ofs.GetTempName
set oWS = CreateObject("Wscript.Shell")
stemp = oWS.Environment("PROCESS")("TEMP") & "\" & stemp
nRes = oWS.Run(sCmdLine & Chr(34) & sTemp & Chr(34) _
, Abs(cSng(bConsoleSw)), True)
alines = "ERRORLEVEL: " & nRes & vbCRLF
if ofs.FileExists(sTemp) Then
with ofs.OpenTextFile(stemp)
if Not .AtEndofStream Then
alines = aLines & .ReadAll
End if
End With
ofs.DeleteFile stemp
alines = Split(aLines, vbNewline)
Else
aLines = Array(nRes, "")
End if
ReDim Preserve alines(Ubound(alines) - 1)
if Err.Number <> 0 Then _
aLines = Array("Error Number:" & CStr(Err.Number),
Err.Description)
CmdPrompt = alines
End Function

sub checkEnter
With window.event
if .keycode = 13 then
runMS_DOS
Else
.cancelbubble = false
.returnvalue = true
End if
End With
End sub

Sub ChDir
Set oSHL = CreateObject("Shell.Application")
On Error Resume Next
Set oFolder = oSHL.BrowseForFolder(&H0,"Select Working
Folder",&H11,&H11)
If Err.Number = 0 Then
CurrentFolder.value = oFolder.Self.Path
Cmd.focus
End if
End Sub

sub Copy
document.ParentWindow.ClipboardData.SetData "text",
Results.innerText
end sub

Sub runMS_DOS
'On Error Resume Next
CreateObject("Wscript.Shell").CurrentDirectory =
CurrentFolder.value
if Err.Number <> 0 Then
aLines = Array("Error Number:" & Hex(Err.Number),
Err.Description)
Else
Results.innerhtml = "</b> Working ...</b>"
aLines = CmdPrompt(Cmd.Value)
End if
Results.innerhtml = "<xmp>" & Join(aLines, vbCRLF) & "</xmp>"
End Sub

</SCRIPT>
</HEAD>
<BODY onload=initialize style="font:11pt Lucinda Console">
</B>Working Folder: &nbsp; &nbsp; </B>
<input type=text id=CurrentFolder size=70>
<input type=button value=Browse onclick=ChDir>
<br>
</B>MS DOS Command: </B>
<input type=text onkeydown=checkEnter size=60 id=Cmd>&nbsp;
<input type=button id=Go value=" GO " onclick=runMS_DOS>
<hr>
<div id=Results>&nbsp</div>
<hr><center>
<input type=button value=" Top "
onclick="scrollto 0,0:Cmd.focus:Cmd.Select"> &nbsp
<input type=button value=" Copy " onclick="copy"> &nbsp
<input type=button value=" Close " onclick="close">
</center>
</BODY>
</HTML>

I saw a posting for the use of an MS combo box suitable for scripting
a while back, but can't google the reference today. It would make a
nice addition as the Command input line by letting you pick a previous
command line by inspection. But, as I said, I can't find it again.

Tom Lavedas
-------------------
My System SpecsSystem Spec
Old 01-11-2009   #6 (permalink)
Todd Vargo


 
 

Re: Batch file (CMD) output into HTA

Tom Lavedas wrote:
Quote:

> On Jan 11, 1:11 am, Daz wrote:
Quote:

>> Hi All,
>>
>> I am wondering if it is possible to have output from a batch file
>> back into a HTA file.
>>
>> What i want to do is use the nice features of HTA to put a nice clean
>> GUI on my batch files. So that instead of having the ugly command
>> text etc, i can have the output back into the HTA and then put some
>> clean type faces etc around it.
>>
>> Is it possible? If so can someone provide and example of HTA code to
>> do it?
>>
>> Any advice or help would be appreciated.
>>
>> Cheers,
>> Daz
>
> Here is an attempt I wrote some time back ...
>
> <HTML>
big snip...
Quote:

> </HTML>
>
> I saw a posting for the use of an MS combo box suitable for scripting
> a while back, but can't google the reference today. It would make a
> nice addition as the Command input line by letting you pick a previous
> command line by inspection. But, as I said, I can't find it again.
Tom, I tried but could not come up with one of these.

Your HTA example is cool but there seems to a few problems with it (read HTA
limitations). The first I noticed was the command line does not seem to work
with internal commands of more than a single parameter. It returns an
errorlevel of 0 but does nothing. Then I tried it with a batch file and it
does permit parameters but if less than the number of parameters expected
are provided, it seems to append a "1" to what is actually expanded.

For example, say the batch has "ECHO parameters=%1 %2 %3" but only two
parameters were provided on the command line (say 'foo bar'), the output is
"parameters=foo bar 1". Where does the 1 come from?

Another thing I noticed (actually, I expected it) is the output is not
displayed in real time. Output is actually displayed after completion of the
command. The output does not seem customizable in the sense of formatting
the output to something pretty.

Don't get me wrong, it was an educational exercise on HTA capability but I
think OP will be happier to just create a shortcut to his existing batch(s)
and set display properties to font and colors desired.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


My System SpecsSystem Spec
Old 01-15-2009   #7 (permalink)
Tom Lavedas


 
 

Re: Batch file (CMD) output into HTA

On Jan 11, 5:29*pm, "Todd Vargo" <tlva...@xxxxxx> wrote:
Quote:

> TomLavedaswrote:
{snip}
Quote:

>
Quote:

> > I saw a posting for the use of an MS combo box suitable for scripting
> > a while back, but can't google the reference today. *It would make a
> > nice addition as the Command input line by letting you pick a previous
> > command line by inspection. *But, as I said, I can't find it again.
>
> Tom, I tried but could not come up with one of these.
>
{snip}

I finally found the Combobox I was sure I had seen recently. I found
a Script Center article, though it was not what I saw originally:
http://www.microsoft.com/technet/scr.../combobox.mspx.
It is probably the source of whatever I saw posted. Don't try to find
it in the index. It doesn't seem to be there (at least I can't find
it). It took a search for CLASSID to turn it up.

Anyway, it works like a champ - if you have MS OFFICE installed. The
implication is that all of the form objects can be used, but you would
need to know the ClassID. I haven't looked for a list of those, but
would have some interest in the Tab control for a project I've been
working on, if anyone stumbles on it.

If anyone reads this and wants a copy of the latest version of the
MSDOSDemo.hta with the combobox in operation, let me know at "tlavedas
at hotmail dot com" (since I don't have a web site at this time).

Tom Lavedas
***********
http://there.is.no.more/tglbatch/
My System SpecsSystem Spec
Old 01-16-2009   #8 (permalink)
p byers


 
 

Re: Batch file (CMD) output into HTA

Tom
Being a 'ScriptSquirrel' - I remembered that I had got some Script (JavaScript)
that creates a "proper" (ish) ComboBox in Web Pages.
I guess that as it works in HTML pages, it can be used in HTA !!

I cannot remember whence it came but if anyone is interested, I will ZIP the
folder concerned and put it on one of my WebSites.

But maybe I have not understood your post !!

Best regards
Take care
Pete (Northolt UK)

Tom Lavedas wrote:
Quote:

> On Jan 11, 5:29 pm, "Todd Vargo" <tlva...@xxxxxx> wrote:
Quote:

> > TomLavedaswrote:
> {snip}
Quote:

> >
Quote:

> > > I saw a posting for the use of an MS combo box suitable for scripting
> > > a while back, but can't google the reference today. It would make a
> > > nice addition as the Command input line by letting you pick a previous
> > > command line by inspection. But, as I said, I can't find it again.
> >
> > Tom, I tried but could not come up with one of these.
> >
> {snip}
>
> I finally found the Combobox I was sure I had seen recently. I found
> a Script Center article, though it was not what I saw originally:
> http://www.microsoft.com/technet/scr.../combobox.mspx.
> It is probably the source of whatever I saw posted. Don't try to find
> it in the index. It doesn't seem to be there (at least I can't find
> it). It took a search for CLASSID to turn it up.
>
> Anyway, it works like a champ - if you have MS OFFICE installed. The
> implication is that all of the form objects can be used, but you would
> need to know the ClassID. I haven't looked for a list of those, but
> would have some interest in the Tab control for a project I've been
> working on, if anyone stumbles on it.
>
> If anyone reads this and wants a copy of the latest version of the
> MSDOSDemo.hta with the combobox in operation, let me know at "tlavedas
> at hotmail dot com" (since I don't have a web site at this time).
>
> Tom Lavedas
> ***********
> http://there.is.no.more/tglbatch/
My System SpecsSystem Spec
Old 01-16-2009   #9 (permalink)
Tom Lavedas


 
 

Re: Batch file (CMD) output into HTA

On Jan 16, 1:26*am, p byers <p...@xxxxxx-ltd.co.uk> wrote:
Quote:

> Tom
> Being a 'ScriptSquirrel' - I remembered that I had got some Script (JavaScript)
> that creates a "proper" (ish) ComboBox in Web Pages.
> I guess that as it works in HTML *pages, it can be used in HTA !!
>
> I cannot remember whence it came but if anyone is interested, I will ZIP the
> folder concerned and put it on one of my WebSites.
>
> But maybe I have not understood your post !!
>
> Best regards
> Take care
> Pete (Northolt UK)
>
> Tom Lavedas wrote:
Quote:

> > On Jan 11, 5:29 pm, "Todd Vargo" <tlva...@xxxxxx> wrote:
Quote:

> > > TomLavedaswrote:
> > {snip}
>
Quote:
Quote:

> > > > I saw a posting for the use of an MS combo box suitable for scripting
> > > > a while back, but can't google the reference today. *It would make a
> > > > nice addition as the Command input line by letting you pick a previous
> > > > command line by inspection. *But, as I said, I can't find it again.
>
Quote:
Quote:

> > > Tom, I tried but could not come up with one of these.
>
Quote:

> > {snip}
>
Quote:

> > I finally found the Combobox I was sure I had seen recently. *I found
> > a Script Center article, though it was not what I saw originally:
> >http://www.microsoft.com/technet/scr...tivex/combobox.....
> > It is probably the source of whatever I saw posted. *Don't try to find
> > it in the index. *It doesn't seem to be there (at least I can't find
> > it). *It took a search for CLASSID to turn it up.
>
Quote:

> > Anyway, it works like a champ - if you have MS OFFICE installed. *The
> > implication is that all of the form objects can be used, but you would
> > need to know the ClassID. *I haven't looked for a list of those, but
> > would have some interest in the Tab control for a project I've been
> > working on, if anyone stumbles on it.
>
Quote:

> > If anyone reads this and wants a copy of the latest version of the
> > MSDOSDemo.hta with the combobox in operation, let me know at "tlavedas
> > at hotmail dot com" (since I don't have a web site at this time).
>
Quote:

> > Tom Lavedas
> > ***********
> >http://there.is.no.more/tglbatch/
Yes, that would be nearly the same thing. However, I suspect it's a
lot of code. I like reusing available system or application objects
whenever possible.

Tom Lavedas
=========
My System SpecsSystem Spec
Old 01-16-2009   #10 (permalink)
Al Dunbar


 
 

Re: Batch file (CMD) output into HTA


"mayayana" <mayaXXyana@xxxxxx> wrote in message
news:%23iA4DeBdJHA.552@xxxxxx
Quote:
Quote:

>> What about the group: alt.msdos.batch.nt
>>
>
> I'm surprised that MS doesn't seem to have more
> relevant groups. DOS/batch isn't relevant here, yet
> there seem to be a lot of people who are interested
> in it. I would have thought that an admin group
> might be best, but even with "admin" the selection
> of Microsoft groups is sparse and specialized. I don't
> see anything like:
> microsoft.public.windows.admin[.scripting]
Two groups here that are occasionally helpful in the area of batch are:

microsoft.public.windows.server.scripting
microsoft.public.win2000.cmdprompt.admin

The first is non-scripting-language specific, and generic to the o/s called
windows server, which covers a few varieties. The second would appear to be
specific to that now obsolete/unsupported o/s called w2k, but it tends to be
somewhat open to more recent versions.
Quote:

> And the DOS groups seem to be only DOS. I guess
> it would help if MS had come up with a name for the
> expanded NT command line functionality, like DOS2,
> NTDOS, or something like that.

The trouble with the term DOS is that that was the name of an o/s that many
of us are no longer using. Yes, I know some still use w9x, some third party
DOS lookalikes, and even real DOS. But since is it no longer supported, I am
not surprised that MS has not created public groups dedicated to it.

This has been discussed before, and IIRC, the consensus was that a
proliferation of batch support groups, one for each possible O/S, would be
confusing.

/Al


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Batch File Vista General
batch file help Vista General
Batch file Vista file management
batch file calling exe file problem Vista security
Need help with batch file 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