Jump to content

Recommended Posts

Posted
I used something knocked up in visual basic. It is located on a shared drive and when a user logs on the script checks to see if the file exists. If it does it shows the message i.e. "USB Memory Pens for sale etc" with jpg or whatever. If the file doesnt exist nothing will be shown.
Posted

Here's a vbs that will do the same thing reading from a text file if the file is empty nothing is displayed.

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.GetFile("C:\motd.txt")

If objFile.Size > 0 Then

Set objReadFile = objFSO.OpenTextFile("C:\motd.txt", 1)

strContents = objReadFile.ReadAll

Wscript.Echo strContents

objReadFile.Close

Else

End If

 

Ben

  • 1 month later...
Posted

Dim StrUsername, Strfilename, Strcomputername, Strmsglocation

 

Strmsglocation = "c:\"

Set objNetwork = WScript.CreateObject("WScript.Network")

strUserName = objNetwork.UserName

strcomputername =objNetwork.ComputerName

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

if objFso.FileExists(Strmsglocation & "motd.txt") then

strfilename = Strmsglocation & "motd.txt"

else

strfilename = Strmsglocation & "null.txt"

end if

Set objFile = objFSO.GetFile(strfilename)

If objFile.Size > 0 Then

Set objReadFile = objFSO.OpenTextFile(strfilename, 1)

strContents = objReadFile.ReadAll

Wscript.Echo strContents

objReadFile.Close

Else

End If

 

 

if objFso.FileExists(Strmsglocation & strusername & ".txt") then

strfilename = Strmsglocation & strusername & ".txt"

else

strfilename = Strmsglocation & "null.txt"

end if

Set objFile = objFSO.GetFile(strfilename)

If objFile.Size > 0 Then

Set objReadFile = objFSO.OpenTextFile(strfilename, 1)

strContents = objReadFile.ReadAll

Wscript.Echo strContents

objReadFile.Close

Else

End if

 

if objFso.FileExists(Strmsglocation & strcomputername & ".txt") then

strfilename = Strmsglocation & strcomputername & ".txt"

else

strfilename = Strmsglocation & "null.txt"

end if

Set objFile = objFSO.GetFile(strfilename)

If objFile.Size > 0 Then

Set objReadFile = objFSO.OpenTextFile(strfilename, 1)

strContents = objReadFile.ReadAll

Wscript.Echo strContents

objReadFile.Close

Else

End if

 

I've done a steroids version of the motd.vbs now you can show 3 messages the first is the normal message of the day, the second is specific to a username and the third is specific to a computer.

 

You set the location of the files at the top of the script in the:

Strmsglocation = "c:\"

 

Variable.

 

Wherever you set that to you need to create a text file called null.txt with nothing in it.

 

motd.txt is the one you create for a system wide message of the day.

 

The other 2 would be username.txt and computername.txt where username and computername are the particular ones you want to message. i.e 00test.txt or 18-01.txt

 

What might be also useful is to have a group feature so that you could have say 18.txt and every machine in 18 would get the message.

 

Hope this is useful to someone.

 

Ben

Posted

How about this:

 

Attach the user motd to the relvant user init GPO

 

or

 

Attach the computer script to a loopack GPO for the OU which groups together the computers in a PC suite.

Posted

Yes you could do those but then you have different copies of the motd script rather than just being able to have a bunch of .txt's in a folder.

 

Ben

  • 7 months later...
Posted

Nice and simple AutoIT script. Just 9 lines of code to do this sort of thing.

 

; AutoIt Version: 3

; Language: English

; Platform: WinXP

; Author: Matt Marsh

; Script Function: Message Of The Day Program

 

$__msgbox = MsgBox(64, 'St Johns Network Message Of The Day', _

'Test message for the St Johns Network Message Of The Day Program.' & @CRLF & _

@CRLF & _

'Matt Marsh - IT Tech' & @CRLF & _

@CRLF & _

'Click on OK to close this box.')

if ($__msgbox = 1) Then

Exit

EndIf

 

Will show this:

 

http://img250.imageshack.us/img250/8434/motd2fx.jpg

 

Compile it to an EXE and run it at logon.

Posted
Nice and short but then you have to recompile it everytime you want to change the message?

 

Which takes seconds, which you can also do in Scite, or even just right clicking over the script.

Posted
Yeah, you can do that - I've done that for a drive mapping script I wrote a while ago. As we only ever use this script maybe once or twice a year its not much bother just to change the syntax and then compile it....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...