Link to home
Start Free TrialLog in
Avatar of chinwish
chinwish

asked on

How to create a pop up message after login using VBS

Hi there,

Wondering if someone can help me out here.

On windows Xp workstations i need to make a message that pops up on the users screen with an OK or close button.

This is for one day only.

I cannot use net send as we disable messenger.
We have too many login scripts to make that method of deployment an option.

I will be using Group Policy in the Active Directory to deploy this.

I snaffled this code from the Microsoft scripting guy website it's a .vbs file referencing an .htm file that has the text i want to popup on the users screens.
I've tested using the code below in a test environment and the basic concept works.
***************************************************
strFile = "MESSAGE.htm"
'strFile = "Message.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile( strFile )

'On Error Resume Next

Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "System Message"  
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=700
objExplorer.Height = 260
objExplorer.Left = 200
objExplorer.Top = 200

Do While (objExplorer.Busy)
    Wscript.Sleep 200
Loop 

objExplorer.Visible = 1

objExplorer.Document.Body.InnerHTML = "<input type='button' onclick='return window.close()' value='Close'/>"
ObjExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & objFile.ReadAll()
Wscript.Sleep 2000
***************************
The message.htm file just has text set to size 15 and font type.

It works but it looks very very basic.

I have tried setting a background colour in the htm file and embeddeing a picture in the htm file but it doesn't show on screen when you run the .vbs

It does show if you view the .htm file.

So could this be done another way? Could it all be done in vbscript - and if so how?  

What i would like to achieve:
Insert a background image
Specify font size and font
Move the 'Close' button so it's under the text and centre not top left which it is at the moment.
INsert a hyper link - under the text in the message which will say something like 'Click here for more information'  (takes them to intranet site)
Could i make the window flash?

I don't want a lot do i?

I do not know anything about scripting so i'd very much appreciate a walkthrough as opposed to hints.

Thank You in advance.
Avatar of chinwish
chinwish

ASKER

Edited Question
Avatar of RobSampson
Hi, I noticed you've got
objExplorer.Navigate "System Message"

does that navigate to a specific page?  I would say, to have more control, you're better off building an HTML page with a span element, that looks the way you want, then you use
objExplorer.Document.All("spanName").InnerHTML = strMessageText

So, I guess the first question is, are you using a separate HTML page?  If not, create one, and use
objExplorer.Navigate "pagename.htm"

Regards,

Rob.
HI,

Thanks for you input.

Not sure I understand - as far as i can tell the objExplorer.Navigate "System Message"  just puts a title in the ie window that opens.
Okay,

Using the following file test.vbs containing the following:

strFile = "MESSAGE.htm"
'strFile = "Message.txt"


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile( strFile )

'On Error Resume Next

Set objExplorer = CreateObject("InternetExplorer.Application")
'objExplorer.Document.All("spanName").InnerHTML = strMessageText
objExplorer.Navigate "Message.htm"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=700
objExplorer.Height = 260
objExplorer.Left = 200
objExplorer.Top = 200

Do While (objExplorer.Busy)
    Wscript.Sleep 200
Loop

objExplorer.Visible = 1


objExplorer.Document.Body.InnerHTML = "<input type='button' onclick='return window.close()' value='Close'/>"
ObjExplorer.Document.Body.InnerHTML = objExplorer.Document.Body.InnerHTML & objFile.ReadAll()
Wscript.Sleep 2000

******************************
And an html file called 'message.htm' containing

<BR>
<BR>
<BR>
<BR>

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

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

<CENTER><A HREF="http://intranet.com" target=_blank">Click Here</A></CENTER>
**********************************
I now have the text the right size colour etc.

What i would like to do is set the background colour to silver.  If i do this in the html file it's fine - but not when you run it from the vbs file.

How do i do this ?

Also can i make the IE Window that opens jump to the front of the screen?

ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is absolutely perfect and doing exactly what i want.

Thank you very much for your help.

No problem.  Thanks for your patience.

Regards,

Rob.