Monday, November 16, 2009

How to create a pop up message after login using VBS and html (From:

OK, now I see what you're trying to do, and this makes it easier to work with.

What I would suggest though, is that you create your HTM file as below, and then only modify that when you want things to change.....

There is one possible catch with this though....because you're using VBScript code inside the HTM file to close the window, if the source of the file location isn't a Trusted Site in IE, then it will pop-up a security warning.  So, I suggest hosting the HTM file on a web server, then placing that server name as a Trusted Site in IE (can be done via Group Policy), and then use VBS to navigate to that page.

So, here's the HTM that I modified:

Login Message
<BODY bgcolor="silver">
<INPUT TYPE='button' onclick='return window.close()' value='Close'/>

<CENTER><SPAN STYLE="color: green; font-size: 20pt">Hello World</SPAN></CENTER>

<CENTER><SPAN STYLE="color: green; font-size: 15pt">To find out more click below</SPAN></CENTER>

<CENTER><A HREF="" target="_blank">Click Here</A></CENTER>

and here's the VBS to load that page:

strFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "Message.htm"

Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Visible = 1
objExplorer.Navigate strFile
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Height = 260
objExplorer.Left = 200
objExplorer.Top = 200

Do While objExplorer.ReadyState <> 4
    Wscript.Sleep 200

' Now activate the window to bring it to the foreground
strWindowTitle = objExplorer.Document.Title & " - Microsoft Internet Explorer"
Set objShell = CreateObject("WScript.Shell")
objShell.AppActivate strWindowTitle
'=================== Print Friendly and PDF

No comments:

Post a Comment