Using NET SEND for a pop-up box

  • Thread starter Thread starter Neko-
  • Start date Start date
N

Neko-

On a request of one of our HR users I've been asked to investigate the
possibility to show a pop-up box during the loginscript to alert users
to certain important messages. Our environment exists primarily of a
Windows 2000/2003 AD, with the workstations being active under Windows
2000 SP4.

I've done a bit of testing and found that NET SEND <username>
"message" would suit our needs best. The loginscript has therefore
been appended with the following (broken up in 3 parts):

Net use L: \\server\netlogon
L:
CD\files
Sc.exe config "messenger" start= auto

C:
Net start messenger
Net use L: /delete

Net send %username% "A notification goes here"

The first part is using the SC command Microsoft released to make sure
the 'Messenger Service' is set to automatically start. This incase
it's disabled through some means.

The second part initiates the acual starting of the 'Messenger
Service' incase this has not yet been started. If it has, it'll
generate an error, but overall nothing to worry about.

The last bit uses the %username% variable (which contains the username
of the user) to initiate the command to send a message to the locally
logged on user.

Now running this batchfile manually on any PC results in it doing
exactly what we expect it to do. The user receives a pop-up box with
the notice just as requested. When running this from the loginscript
however, it fails.

The last command is filled in with the correct username (this has been
verified by pausing the script and checking the actual command
syntaxes given), and then returns an error:

An error occurred while sending a message to <username>.
The message alias could not be found on the network.
More help is available by typing NET HELPMSG 2273.

What I have found is that this means the username is not yet known on
the network, eventho the user has just logged in and authenticated.
More mind-boggeling is the fact that after logging in (and the failure
exhibiting itself) and then running a manual session of the same login-
script results in it doing exactly what we would expect it to do,
namely pop-up the box.

Anyone have any thoughts on this?

Thanks in advance,
J. van Doornik
 
I'm not surprised. NET SEND doesn't use DNS and at the time of login only
DNS can be known to be stable ... so ...

Why not use a batch file and some ECHO commands instead?

@echo off
echo "This is an important message!"
echo "If you read it you will know why"
pause

This batch/CMD file displays text in a window and waits for the user to
press a key to continue.

--
Richard G. Harper [MVP Shell/User] (e-mail address removed)
* NEW! Catch my blog ... http://msmvps.com/blogs/rgharper/
* PLEASE post all messages and replies in the newsgroups
* The Website - http://rgharper.mvps.org/
* HELP us help YOU ... http://www.dts-l.org/goodpost.htm
 
If you want a pop-up box then you could use this script
instead of the "net send" command:

@echo off
echo>c:\temp\Message.vbs Result = MsgBox("Hello world", 0, "Good morning")
cscript //nologo c:\temp\Message.vbs
 
If you want a pop-up box then you could use this script
instead of the "net send" command:

@echo off
echo>c:\temp\Message.vbs Result = MsgBox("Hello world", 0, "Good morning")
cscript //nologo c:\temp\Message.vbs
This actually looks like something I can use. The using of the command
prompt usually doesn't alert users that much, so they tend to ignore
it since it's mixed in with a few responses from the loginscript
itself. The popup box through a VBS script however alerts them to
something going on.

Unfortunatly I'm not that versed in VBS, and thus am going to have to
do a bit of digging to find out what can and can't be done. But it's
good to know a possible cause for the notice not to work through the
loginscript, aswell as a possible work-around for it.

Thanks!!! :)

J. van Doornik
 
Back
Top