PC Review


Reply
Thread Tools Rate Thread

Batch job question

 
 
Pete
Guest
Posts: n/a
 
      2nd May 2009
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?
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      2nd May 2009

"Pete" <Noentry@unknownhost> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      3rd May 2009
Pegasus [MVP] wrote:
> "Pete" <Noentry@unknownhost> wrote in message
> news:(E-Mail Removed)...
>> 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.
>
>


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.
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      3rd May 2009

"Pete" <Noentry@unknownhost> wrote in message
news:(E-Mail Removed)...
> Pegasus [MVP] wrote:
>> "Pete" <Noentry@unknownhost> wrote in message
>> news:(E-Mail Removed)...
>>> 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.

>
> 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


 
Reply With Quote
 
John John - MVP
Guest
Posts: n/a
 
      3rd May 2009
Pete wrote:
> Pegasus [MVP] wrote:
>> "Pete" <Noentry@unknownhost> wrote in message
>> news:(E-Mail Removed)...
>>> 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.
>>

>
> 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
 
Reply With Quote
 
Andrew McLaren
Guest
Posts: n/a
 
      3rd May 2009
>> 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


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
--
amclar at optusnet dot com dot au


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      3rd May 2009

"Andrew McLaren" <(E-Mail Removed)> wrote in message
news:O0XNF%23%(E-Mail Removed)...
>>> 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

>
> 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.


 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      3rd May 2009
John John - MVP wrote:
> Pete wrote:

<snip>
> 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.
 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      3rd May 2009
Andrew McLaren wrote:
>>> 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

>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: --->Batch command question<--- Jon Windows Vista General Discussion 0 6th Feb 2010 11:35 PM
batch question David K Windows XP General 5 16th Oct 2006 09:54 AM
Question about batch file programmernovice@yahoo.com Windows XP General 3 30th Jul 2006 05:05 AM
Batch question Howard Brazee Windows XP General 8 8th Dec 2005 06:27 PM
Re: Batch question Brother Brock Windows XP General 0 24th Aug 2005 10:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:21 PM.