Batch job question

P

Pete

How can a get a batch job to pop up a message? The message has to
survive the PC's going to standby and waking up.

Background:
My external drive's power supply failed and so my nightly scheduled
backup job naturally couldn't complete. However, I didn't figure this
out for a couple of days until I went to manually check the drive for
something. In case the problem happens again, I want to know sooner.

In "Scheduled Tasks," the Last Result is 0x1, which I assume is an error
code (normal result is 0x0). Following my discovery, I checked "Notify
me of missed tasks" in the Advanced menu of Scheduled Tasks, but the
next morning there was no notification that I could see -- no popup on
the screen and no entry in the Event Viewer.

Scheduled Task's log shows "Result: The task completed
with an exit code of (1)" but perhaps the task scheduler doesn't
interpret that as a "missed task."

I could create a batch job that checks the Errorlevel following the
scheduled task, which ought to detect the 0x1 return code, but what do I
use for the "command" in order to get a display? The only thing I can
think of is

@echo off
backupjob.exe
If not errorlevel 1 then goto end
cmd /k
echo warning -- task failed
:end


but that seems a bit kludgy. Any more elegant solutions?
 
P

Pegasus [MVP]

Pete said:
How can a get a batch job to pop up a message? The message has to survive
the PC's going to standby and waking up.

Background:
My external drive's power supply failed and so my nightly scheduled
backup job naturally couldn't complete. However, I didn't figure this
out for a couple of days until I went to manually check the drive for
something. In case the problem happens again, I want to know sooner.

In "Scheduled Tasks," the Last Result is 0x1, which I assume is an error
code (normal result is 0x0). Following my discovery, I checked "Notify
me of missed tasks" in the Advanced menu of Scheduled Tasks, but the
next morning there was no notification that I could see -- no popup on
the screen and no entry in the Event Viewer.

Scheduled Task's log shows "Result: The task completed
with an exit code of (1)" but perhaps the task scheduler doesn't interpret
that as a "missed task."

I could create a batch job that checks the Errorlevel following the
scheduled task, which ought to detect the 0x1 return code, but what do I
use for the "command" in order to get a display? The only thing I can
think of is

@echo off
backupjob.exe
If not errorlevel 1 then goto end
cmd /k
echo warning -- task failed
:end


but that seems a bit kludgy. Any more elegant solutions?

Here you go:
@echo off
backupjob.exe || net send %ComputerName% "Warning: Backup task failed"

You must make sure that the Messenger service is running.
 
P

Pete

Pegasus said:
Here you go:
@echo off
backupjob.exe || net send %ComputerName% "Warning: Backup task failed"

You must make sure that the Messenger service is running.

Thanks. I had disabled the Messenger service long ago because of some
type of spam (I forget what exactly), but I'll give this a try. Perhaps
the spammers have moved on to new technologies.

I suppose if I want to get really creative, I can shoehorn in a net
start command, leaving the Messenger service enabled but not
automatically started on boot.
 
P

Pegasus [MVP]

Pete said:
Thanks. I had disabled the Messenger service long ago because of some type
of spam (I forget what exactly), but I'll give this a try. Perhaps the
spammers have moved on to new technologies.

I suppose if I want to get really creative, I can shoehorn in a net start
command, leaving the Messenger service enabled but not automatically
started on boot.

You can leave it disabled if you wish:

sc config messenger start= demand
sc start messenger
net send . . .
sc stop messenger
sc config messenger start= disabled
 
J

John John - MVP

Pete said:
Thanks. I had disabled the Messenger service long ago because of some
type of spam (I forget what exactly), but I'll give this a try. Perhaps
the spammers have moved on to new technologies.

As Pegasus has already pointed out you don't need to have the service
set to start automatically but if you were receiving messenger spam you
were not using a firewall or your firewall was incorrectly configured.

John
 
A

Andrew McLaren

Here you go:
Thanks. I had disabled the Messenger service long ago because of some

If you have XP Pro, you can probably use the "msg" command, in lieu of "net
send". msg does not require the Messenger Service to be running.

Type "msg /?" at the Prompt, to see the full syntax.

Hope it helps a bit,

Andrew
 
P

Pegasus [MVP]

Andrew McLaren said:
If you have XP Pro, you can probably use the "msg" command, in lieu of
"net send". msg does not require the Messenger Service to be running.

Type "msg /?" at the Prompt, to see the full syntax.

Hope it helps a bit,

Andrew
--

Nice. I've been working at the Command Prompt for countless years but I was
unaware of this command until I read your reply! I now prefer msg.exe to
"net send" because it does not rely on the messenger service and because of
the various options it offers.
 
P

Pete

John said:
Pete wrote:
As Pegasus has already pointed out you don't need to have the service
set to start automatically but if you were receiving messenger spam you
were not using a firewall or your firewall was incorrectly configured.

John

Thanks. After I wrote that, I did a little Googling to refresh my
recollection. I must have disabled the Messenger service back in XP
Gold days, before the ICF/Windows Firewall blocked incoming multicast
and broadcast traffic. I never missed the Messenger service, so I never
re-enabled it even after WF was configured to block that stuff.
 
P

Pete

Andrew said:
If you have XP Pro, you can probably use the "msg" command, in lieu of "net
send". msg does not require the Messenger Service to be running.

Type "msg /?" at the Prompt, to see the full syntax.

Hope it helps a bit,

Andrew

Great thanks. Back in the day, you could read a paper manual with all
the commands and syntax (if you were so inclined). Today, it's all
online, but only helpful if you know where to look.
 

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

Top