Re: Status windows instead of wScript.Echo by Jordan
Jordan
Fri Feb 29 16:01:44 CST 2008
Thanks, this looks like it will do the trick. I have just one question
since it is a little different than what I have been using.
The VBscript that I was going to be writing going to be something that runs
as a scheduled taks under a local admin account. If person is not logged
in, would this method still run or does this method require a user to be
logged on an running it from the console?
"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
news:%23zFrosxeIHA.6136@TK2MSFTNGP03.phx.gbl...
> Jordan wrote:
>> I would like to monitor my steps in my script, but the only way I know
>> how
>> is to do wScript.Echo "Blah blah blah".
>>
> hi Jordan,
>
> Yes, it's annoying that vbs doesn't have a better graphical
> user interface (GUI), other than askboxes and msgboxes.
>
> The usual advice you get here is to use IE, or an HTA app
> to show a graphical interface.
>
> There is an HTA template attached that shows a panel for
> debugging messages attached.
>
> That will get you going.
>
> If you have time, you might also wish to look at "wshDialog"
> utility for showing "Forms", and also "KixForms" which was
> intended for use with the Kixtart scripting language, but
> which works perfectly well with vbs too.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>
>
--------------------------------------------------------------------------------
> <HTML>
> <HEAD>
>
> <script language="vbscript">
> ' --- discussion (avoiding that annoying hta "dialog bounce") ---
> ' this "trick" found on the vbScript ng, code by mikHar, 05Sept06
> ' Normally, an hta dialog will initially be shown in its "default"
> ' position and size for a brief instant. Later, when it gets
> ' around to running your script code, it will move/resize itself
> ' according to your wishes. Placing the move/resize code AHEAD
> ' of the hta tag seems to avoid that...
> ' --- end of discussion ----------------------
>
> Const wdDlg = 600, htDlg = 380 ' dialog size
> Const pxLeft = 100, pxTop = 100 ' positioning
> window.ResizeTo wdDlg,htDlg
> window.MoveTo pxLeft,pxTop
> </script>
>
> <HTA:APPLICATION ID="oHTA" APPLICATIONNAME="htaDebugDialogTemplate"
> WINDOWSTATE="normal" SCROLL = "no" BORDERSTYLE="normal" BORDER="thin"
> CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" ICON="mru.ico"
> SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" >
>
> <TITLE> << (hta) Debug Dialog Template (with Fake
> StatusBar) Demo Script >> </TITLE>
>
> <SCRIPT LANGUAGE="vbScript">
> <!--
>
> ' --- description block --------------------------
> '
> ' Title: (hta) debug dialog with Fake StatusBar, jw 12May06
> '
> ' Description: A scripting graphical user interface (gui),
> ' appropriate for posting debugging messages or status msgs.
> ' Due to difficulties with posting messages to microsoft's
> ' IE statusbar, there is also a "fake" statusbar included...
> '
> ' Author: mr_unreliable
> ' Website: none at this time (but lurks around the wsh/vbs ng's)
> '
> ' Usage: Use at you own risk, tested on win98se...
> '
> ' Acknowledgments: xx/xx/xx a "xxx yyy" of the vbs newsgroup
> ' offered up an anternative to my "brute force" approach
> ' to scrolling, i.e., "scrolldown". He suggested using
> ' "scroll into view". His approach was incorporated here
> ' (although so vastly modified as to probably be unrecognizable
> ' to xxx).
> '
> ' --- revision history ---------------------------
> ' 12May06: initial attempt (working from "regular" hta dbDlg)...
> ' 13May06: added "working clock"...
> ' 20May06: added "scroll into view" option for scrolling...
> ' --- end of description block -------------------
>
> Option Explicit
>
> ' --- global variables ---------------------------
> '
> ' Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
> ' Dim oShell : Set oShell = CreateObject("WScript.Shell")
> '
> Dim oDoc ' as document object
> Dim clkTmr ' as timer (used to update clock)
> Const clkTmrInt = 995 ' clock update interval (note: LESS THAN 1 SEC)
> '
> Dim tRun ' as long (to keep track of running time)
> Dim iItem ' as integer (to keep track of "span" tags)
> Dim iMsg ' as integer (sequential number, to keep track of messages)
> Const bAlignWithTop = True
> Const bAlignWithBottom = False
> ' --- end of declarations and constants ----------
>
>
> ' --- initialize window size & positioning -------
> ' Const wdDlg = 500, htDlg = 280 ' dialog size
> ' do a little adjusting of my size and location...
> ' window.ResizeTo wdDlg,htDlg
> ' window.MoveTo 100,100
>
>
> ' --- INITIALIZATION ROUTINE ---------------------
>
> Sub initDialog()
> Const sMe = "[initDialog], "
>
> ' do a little adjusting of my size and location...
> ' window.ResizeTo wdDlg,htDlg
> ' window.MoveTo 100,100
> Set oDoc = window.document
>
> With oDoc
> ' resize text area...
> oDoc.getElementById("msgList").style.width = wdDlg - 25
> ' htClientArea, less statusbar, logo, less button, less progbar, less...
> oDoc.getElementById("msgList").style.height = oDoc.body.clientHeight _
> - 25 - 20 - 35 - 20 ' (and less fudge factor, but don't tell
> anybody)...
>
> ' MsgBox("Client Width: " & oDoc.body.clientWidth _
> ' & "Client Height: " & oDoc.body.clientHeight)
>
> ' re-position the logo to lie just above the (fake) statusbar...
> oDoc.getElementById("logo").style.top = oDoc.body.clientHeight - 47
> oDoc.getElementById("logo").style.left = oDoc.body.clientWidth - 215
>
> ' re-position the (fake) statusbar at the bottom of the form (er,
> dialog)...
> oDoc.getElementById("etchedEdge").style.top = oDoc.body.clientHeight - 25
> oDoc.getElementById("fakeStatusBarFrame").style.top =
> oDoc.body.clientHeight - 23
>
>
> ' oDoc.getElementById("btnExit").disabled = False
> oDoc.getElementById("btnExit").onClick = GetRef("btnExit_Click")
> End With
>
> ' place a message in the main statusbar panel...
> oDoc.getElementByID("statusPanel1").innerText = " The ""Main"" statusbar
> panel text goes here "
>
> ' place the current time in the clock panel of the statusbar...
> oDoc.getElementByID("statusPanel2").innerText = " Time: " _
> & formatDateTime(Time, vbLongTime)
>
> ' set clock timer, (used to update the clock)...
> ClearInterval(clkTmr) : clkTmr = setInterval("clkTimer_Event", clkTmrInt,
> "vbscript")
>
> tRun = 0 ' initialize the running time...
> iItem = 0
>
> dbPrint sMe & "finished.. "
>
> ' hiding the dbMsgs, for now...
> oDoc.getElementByID("msgLabel").style.visibility = "visible" ' "hidden"
> oDoc.getElementByID("msgList").style.visibility = "visible" ' "hidden"
>
> End Sub
>
>
> ' --- SIMULATE DEBUG.PRINT -----------------------
>
> Sub dbPrint(sMsg) ' simulates debug.print...
> Dim msgID ' as string
>
> ' posting messages and scrolling down (take II)...
> ' In this version, the posted messages are "wrapped" into "span tags",
> ' and given an "id" attribute containing the "message number",
> ' then inserted into the listing...
> msgID = "msg" & CStr(iMsg)
> oDoc.getElementById("msgList").insertAdjacentHTML "BeforeEnd", _
> "<span id=""" & msgID & """ >" & sMsg & "<br></span>"
>
> ' and the current/last span tag (message) is scrolled into view...
> oDoc.getElementByID(msgID).scrollIntoView(bAlignWithBottom)
>
> ' also, publish the current dbMessage in the (fake) statusbar panel...
> oDoc.getElementByID("statusPanel1").innerText = " " & sMsg
>
> iMsg = iMsg + 1 ' bump up for next message
> End Sub
>
>
> ' ------------------------------------------------
> ' --- EVENT HANDLERS -----------------------------
> ' ------------------------------------------------
>
> Sub clkTimer_Event() ' update the clock
> Const sMe = "[timer], "
>
> ' msgbox("timer event detected")
> oDoc.getElementByID("statusPanel2").innerText = " Time: " _
> & formatDateTime(Time, vbLongTime)
>
> ' every to often, post a debug message, just for the entertainment
> value...
> tRun = tRun + 1
> ' if ((tRun mod 10) = 0) then dbPrint sMe & "elapsed time: " & CStr(tRun)
> & " secs"
> dbPrint sMe & "elapsed time: " & CStr(tRun) & " secs"
> End Sub
>
>
> Sub btnExit_Click()
> Const sMe = "[btnClick], "
> ' MsgBox("detected Click Event")
> ClearInterval(clkTmr) ' stop the clock timer
>
> ' post a notification to the debug window...
> dbPrint "" ' space
> dbPrint sMe & " ..detected Exit Button Click Event "
> dbPrint sMe & " (this window will close in 1 sec) "
>
> ' wait-a-bit, to allow for reading the msg,
> ' by setting ANOTHER timer, to close this dialog window...
> SetTimeout "Window.Close", 1000
>
> End Sub
>
>
> Sub CleanUp()
>
> ' msgbox("onUnload event detected")
> ClearInterval(clkTmr)
> End Sub
>
>
>
>
> //-->
> </SCRIPT>
> <style>
> body {font-family: ms sans serif; font-size: 10pt; font-weight: 400;
> color: Navy;
> margin-top: 4px; margin-left: 1px; margin-right: 1px; margin-bottom:
> 1px;
> height: 10px; width: 10px; border-style: none; }
> div {border-style: inset; border-width: 2; background-color:aliceblue;
> overflow:auto; text-align:left;
> font-family:verdana; font-size:10pt; font-weight:400; color:Navy; }
> textarea {font-family: verdana; font-size: 10pt; font-weight: 400; color:
> Navy; }
> button {margin-top: 7px; height: 25px; width: 100px; font-family:
> verdana; font-weight: 600;
> width: 125px; }
>
> h3 {margin-top: 3px; margin-bottom: 2px; padding-top: 0%; padding-bottom:
> 0%;
> font-family: verdana; font-size: 8pt; font-weight: 400; color:
> Navy; }
> h4 {position:absolute; top:100; left: 2;
> margin-top: 6px; margin-bottom: 0px; padding-top: 0%; padding-bottom:
> 0%;
> font-family: Arial; font-size: 8pt; font-weight: Normal; font-style:
> Italic;
> color: Navy; }
>
> hr {position:absolute; top:100; left: 2; margin-top: 1px;
> margin-bottom: 1px; }
> table {position:absolute; top:110; left: 1; margin-top: 1px;
> margin-bottom: 1px;
> border-style: none; border-width: 1; width: 100%; height: 20px; }
> td {border-style: inset; border-width: 2;
> font-family: verdana; font-size: 8pt; font-weight: normal; color:
> Navy }
> </style>
> </HEAD>
>
> <!-- this is the "mother" (a.k.a. "debug dialog") page -->
> <BODY onload="initDialog()" onUnload="CleanUp()" scroll='no' text='navy'
> bgcolor="silver" >
> <h3 id="msgLabel" > debugging messages... </h3>
> <CENTER>
> <!-- using "div" element (instead of textarea) for posting messages,
> instead of a listbox (i.e., what you would have used in vb)... -->
> <DIV id="msgList" >
>
> </DIV>
>
> <BUTTON id="btnExit" onclick="window.close()" >Exit</BUTTON>
> </CENTER>
>
> <h4 id="logo" ALIGN=RIGHT > jawar productions (all rights
> reserved)... </h4>
>
> <!-- using table as (fake) statusbar. (with "inset" border) -->
> <hr id="etchedEdge" width=99% align=center >
> <TABLE id="fakeStatusBarFrame" width=99% bgcolor=silver align=center ><TR>
> <TD id="statusPanel1" bgcolor=silver >
> <TD id="statusPanel2" style="width: 120px; "> Time 12:00:00
> </TR></TABLE>
>
> </BODY>
> </HTML>