Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Show status message of the script

220 views
Skip to first unread message

Maw

unread,
Jun 10, 2010, 11:38:35 AM6/10/10
to
Hi all,
i want find a way to show in a popup or in ie windows a status message
of the script:


.....part of the some script in a loop

For Each objUser in objOldOU
strstreetAddress = objUser.Get("streetAddress")
'wscript.echo strstreetAddress
Select Case (strstreetAddress)
Case "MI- Europa"
oudest = "LDAP://ou=Utenti,ou=Europa,ou=Sedi," & varDomainNC
objUser.Put "scriptPath", "europa.cmd"
MESSAGE = "SELECT CASE 1"
Case "Cavallotti"
oudest = "LDAP://ou=Utenti,ou=Cavallotti,ou=Sedi," & varDomainNC
objUser.Put "scriptPath", "cavallotti.cmd"
MESSAGE = "SELECT CASE 2"
Case "Broletto"
oudest = "LDAP://ou=Utenti,ou=Broletto,ou=Sedi," & varDomainNC
objUser.Put "scriptPath", "broletto.cmd"
MESSAGE = "SELECT CASE 3"
Case "Mi - Sempione"
oudest = "LDAP://ou=Utenti,ou=Sempione,ou=Sedi," & varDomainNC
objUser.Put "scriptPath", "sempione.cmd"
MESSAGE = "SELECT CASE 4"
End Select
objUser.SetInfo
Set objNewOU = GetObject(oudest)
WSCRIPT.ECHO MESSAGE
objNewOU.MoveHere objUser.ADsPath, vbNullString

It's possible open a message and close it after some second without
the user click on some button?
Thx in advance.

Maw

Tom Lavedas

unread,
Jun 10, 2010, 1:28:34 PM6/10/10
to

The simplest solution if the Wscript.Shell Popup function ...

Set WshShell = CreateObject("WScript.Shell")
WshShell.Popup "Your message here", 5, "Title", vbOkay +
vbExclamation

See the WSH documentation for more information.
WSH 5.6+ documentation download (URL all one line)
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

The other approach is to build your own adaptable display through the
IE document object model. I've posted a number of examples here in
the past. Try a groups.google search.
_____________________
Tom Lavedas

Dave "Crash" Dummy

unread,
Jun 10, 2010, 2:49:57 PM6/10/10
to
Tom Lavedas wrote:

<snipped>

> The other approach is to build your own adaptable display through the
> IE document object model. I've posted a number of examples here in
> the past. Try a groups.google search.

I like using HTA scripts for dynamic displays.
--
Crash

"The real question is not whether machines think but whether men do."
~ B. F. Skinner ~

Maw

unread,
Jun 11, 2010, 3:28:02 AM6/11/10
to
> WSH 5.6+ documentation download (URL all one line)http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207...

>
> The other approach is to build your own adaptable display through the
> IE document object model.  I've posted a number of examples here in
> the past.  Try a groups.google search.
> _____________________
> Tom Lavedas

Hi,
i like the WshShell.Popup but i don't want the button, it's possible?

And HTA for me it's a new way, i don't know the code!!!

thx

Dave "Crash" Dummy

unread,
Jun 11, 2010, 4:11:45 AM6/11/10
to

No.

> And HTA for me it's a new way, i don't know the code!!!

It is the same as a scripted web page except with a HTA extension
instead of HTM, and you have all the privileges of a VBS script.
http://en.wikipedia.org/wiki/HTML_Application
--
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~

Tom Lavedas

unread,
Jun 11, 2010, 11:01:40 AM6/11/10
to
On Jun 11, 4:11 am, "Dave \"Crash\" Dummy" <inva...@invalid.invalid>
wrote:
> instead of HTM, and you have all the privileges of a VBS script.http://en.wikipedia.org/wiki/HTML_Application

> --
> Crash
>
> "When you get to a fork in the road, take it."
> ~ Yogi Berra ~

Here is a no button box using IE, which can be integrated into an
existing VBS script ...

sMessage = "This is your message"
nobtnbox sMessage, 3, "Title goes here"
nobtnbox "<b>" & sMessage & " emphasized", 3, "Title goes here"
nobtnbox "<font color=red>" & sMessage & "in red", 3, "Title goes
here"

Sub NoBtnBox(sMsg, nWait, sTitle)
Dim Height, Width, oIE

' Default values ...
height = 100 : width = 400

set oIE = CreateObject("InternetExplorer.Application")
With oIE
.RegisterAsDropTarget = False
.toolbar = false : .statusbar = false
.menubar = false : .addressbar = false
.width = Width : .height = Height
.Navigate "about:blank"
Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop
With .document
.open
.write "<html><head><title>MsgBox ...</title></head>" _
& "<body id=bdy bgColor=silver scroll=no " _
& "style='font-family:sans-serif'><center>" _
& "<span id=msg></spam></center></body></html>"
.close
Do Until oIE.ReadyState = 4 : WScript.Sleep 50 : Loop
With .parentWindow.screen
oIE.left = (.width - oIE.width )\ 2
oIE.top = (.height- oIE.height)\ 2
End With
.title = sTitle
.all.msg.innerHTML = sMsg
End With ' document
.Visible = True
CreateObject("Wscript.Shell").AppActivate "MsgBox ..."
End With ' IE
wsh.sleep nWait * 1000
oIe.Quit
End sub

Unfortunately, IE versions of 7 and above prohibit removal of the
title bar and recent Hotfixes added an http:// prefix for all URLs,
even "about:blank". It can actually be done using an HTA that is
built on-the-fly, but it's way too complicated. The only reason a
person would do that would be to get rid of that ugly title bar. In
general, it's probably not worth the bother - it may be better to go
out and find a third party control that does it easier and better.
_____________________
Tom Lavedas

Tom Lavedas

unread,
Jun 11, 2010, 3:13:53 PM6/11/10
to
On Jun 11, 11:01 am, Tom Lavedas <tglba...@verizon.net> wrote:
{snip}

> It can actually be done using an HTA that is
> built on-the-fly, but it's way too complicated.  The only reason a
> person would do that would be to get rid of that ugly title bar.  In
> general, it's probably not worth the bother - it may be better to go
> out and find a third party control that does it easier and better.
> _____________________
> Tom Lavedas

It turned out to be much easier than I thought, thanks to a
trick"Mayayana" posted here not too long ago ...

set oMsgBox = NewMsgBox("lightgrey")
oMsgBox.document.title = "No Button Message Box"
oMsgBox.msg.innerText = "A new message"
wsh.sleep 5000
oMsgBox.close

Function NewMsgBox(sBgColor)
Dim IE, HTA

with CreateObject("WScript.Shell")
.Run "MSHTA.EXE " _
& """javascript:new ActiveXObject('InternetExplorer.Application')"
_
& ".PutProperty('ID1',window);""", 1, False

do until .AppActivate("javascript:new")
WScript.sleep 50
loop
end with ' Shell

For Each IE In CreateObject("Shell.Application").Windows
If IsObject(IE.GetProperty("ID1")) Then
Set HTA = IE.GetProperty("ID1")
HTA.resizeTo 300,100 : HTA.moveto 500, 400
with HTA.document
.write "<HTA:Application contextMenu=no border=dialog " _
& "minimizebutton=no maximizebutton=no sysmenu=no />" _
& "<body scroll=no style='background-color:" _
& sBgColor & ";font:normal 12pt Arial'>" _
& "<center><span id=msg>&nbsp;</span><center></body>"
end with
IE.quit
Exit For
End If
Next

set NewMsgBox = HTA

End Function

This is intended as a bare bones prototype that can be modified to
meet particular needs. I built this version to pass the HTA object
back to the calling program. This allows full DHTML access to the
entire DOM, making for the highest possible versatility. The function
can be tailored to do the whole job, retuning only when the message
timeout is reached.

The big advantage of this approach is the removal of all of the IE
'chrome'. The disadvantage is that the initial HTA frame flashes onto
the screen, before it is resized to the programmed sizes. This is
usually suppressed in a standalone HTA by placing a 'resizeTo'
statement at the very top of the file before any other definitions or
scripting. I haven't figured out how to emulate that here.
_____________________
Tom Lavedas

James Whitlow

unread,
Jun 11, 2010, 7:40:58 PM6/11/10
to
"Tom Lavedas" <tglb...@verizon.net> wrote in message
news:422ff750-711d-44f5...@k39g2000yqd.googlegroups.com...

On Jun 11, 11:01 am, Tom Lavedas <tglba...@verizon.net> wrote:
{snip}

I am not sure if it is in scope for what OP asked for, but you can alter
this to have a message box with a timeout that does not stop the script by
using the 'execScript' method. Just remove the 'wsh.sleep 5000' &
'oMsgBox.close' lines from the above script and replace them with:

oMsgBox.document.parentWindow.execScript _
"setTimeout ""window.close()"", 5000", "VBScript"


Tom Lavedas

unread,
Jun 12, 2010, 7:40:47 AM6/12/10
to
On Jun 11, 7:40 pm, "James Whitlow" <jwhitlow.60372...@bloglines.com>
wrote:
> "Tom Lavedas" <tglba...@verizon.net> wrote in message

Yes, great idea.
______________________
Tom Lavedas

Maw

unread,
Jun 14, 2010, 3:50:35 AM6/14/10
to
I all,
i have find this easy solution:

Set objExplorer =
WScript.CreateObject("InternetExplorer.Application","IE_")
objExplorer.Navigate "about:blank"
' size of window
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 100
objExplorer.Left = 0
objExplorer.Top = 0
' window visible and starting message
objExplorer.Visible = 1
objExplorer.Document.Body.scroll = "no"

and when you need to print the message i put the code below:
objExplorer.Document.Body.InnerHTML = "Connection to AD..."
wscript.sleep(500)

it's easy but good to understand where is the script.

Only one question: It's possible remove the title bar???

Thx to all for the reply.

bye

Tom Lavedas

unread,
Jun 14, 2010, 8:21:25 AM6/14/10
to

If the machine running the script has IE 7 or later installed, the
answer is NO. For IE6 or earlier, the answer is that it can be done
by first setting the FullScreen property to True and THEN reset the
Height and Width properties to the desired values.

However, the HTA solution that I posted CAN remove the title bar.
Simply change the borderstyle property to None. However, since the
title bar in my solution has no buttons and a title that is under user
control, there really is little reason to remove it.

As far as setting it's message, it works exactly like the IE
solution. That is, the body.innerHTML can be used to set the message
(though it is a bit simpler to just use the Msg object that the
function provides.
_____________________
Tom Lavedas

0 new messages