Pop-up window from command-line

  • Thread starter Thread starter Rich Pasco
  • Start date Start date
R

Rich Pasco

I would like to pop up a window with a message from a command line
(e.g. BAT file).

If my computer is on a network, this command line works:

net send mymachine Hello World!

where mymachine is the network name of my own machine.

But this only works if my machine is on a network. Can anyone suggest
a technique that would work on a stand-alone machine as well?

- Rich
 
This should work regardless of whether you have a network connection. The
net send relies only the messenger service running. You should be able to
unplug your network cable and net send yourself just fine.

I suggest that you net send LOCALHOST or %COMPUTERNAME% instead of
hard-coding your computername in the .bat file though.

Ray at work
 
Ray, thank you.

It may work if I unplug my network *cable* but it doesn't work if I
unplug my network *card* (which I often do on my laptop).

I tried LOCALHOST and it doesn't work at all (even with the network
active). I get:

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

Of course %computername% is resolved by the command shell and is
equivalent to what I was doing. That is a good idea.

- Rich
 
Is your messenger service running? Try this:

1. At the command prompt, enter "net start messenger"
2. Unplug your network card and wait 30 seconds for good measure
3. Again, enter "net start messenger"

Did the messenger service start either time?

Another option is to do something like:

cscript c:\msg.vbs "Hi there."

Where the contents of msg.vbs are:

On Error Resume Next
Msgbox WScript.Arguments(0)

Ray at work
 
I would like to pop up a window with a message from a command line
(e.g. BAT file).

echo msgbox "Message!">%temp%\message.vbs
%temp%\message.vbs
del %temp%\message.vbs
 
With my network card removed, I could not send a message to
myself, even though the messenger service was still running:

C:\>net send %computername% hello
An error occurred while sending a message to PASCO-LAPTOP.
The message alias could not be found on the network.
More help is available by typing NET HELPMSG 2273.

C:\>net start messenger
The requested service has already been started.
More help is available by typing NET HELPMSG 2182.

C:\>net send %computername% hello
An error occurred while sending a message to PASCO-LAPTOP.
The message alias could not be found on the network.
More help is available by typing NET HELPMSG 2273.

Of course with the network card installed the same command
results in the pop-up window as desired.

I really like the VBScript solution better. It works OK even
in the absence of the network card. However, it still doesn't
solve my whole problem. The context in which I was planning
to use it is as follows:

at 8:43 /interactive c:\test\msg.vbs "Hello World"

In this context, the script msg.vbs cannot find its command-line
argument "Hello World." If I disable the "On Error Resume Next"
statement it gives a "Subscript out of range" error; otherise
it exits silently.

- Rich
 
at 8:43 /interactive c:\test\msg.vbs "Hello World"

I cannot explain why this fails, but this workaround seems to work, at
least on my XP machine:

at 8:43 /interactive wscript c:\test\msg.vbs "Hello World"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top