November 22, 2005 at 5:21 am
I have a problem where a net send message is send 20 times to the affected console instead of once.
I am developing a capture system with some background service processing. For certain conditions, i need to send a message to the workstation where the capture happened. To that end, I store the name of the workstation as known to the domain. I then have a update trigger monitoring a table for updates. If the condition I am monitoring occurs, I send a message to the console using the following command:
exec master..xp_cmdshell @command
@command is a declared variable that I set up with the following command:
net send domain\workstation message
where:
domain is my domain name
workstation is the workstation name stored on the capture table
message is the message I am sending
The above command is fired only once but the message pops up 20 times on the console. Help!
November 22, 2005 at 3:21 pm
Without seeing any of the code you're using it's a little hard to give an clear response.
Best guess would be that your executing the xp_cmdshell from the trigger and the trigger is firing 20 times.
--------------------
Colt 45 - the original point and click interface
November 23, 2005 at 6:39 am
Yup, I agree with Phil...
Two ways around this - use a stored proc to encapsulate the logic...
OR
Have some sort of "messageLog" table - when you send a message, first check to see if you haven't already sent a message to that computer in the last X minutes (and perhaps for event Y if you want to still send multiple messages in succession if multiple events occur). If you have sent a message recently, then just update the "lastSentMessage" column in the log table.
If you haven't sent a message recently, either because you had a row in the log table with an old lastSentMessage time, or because you found no row in the table, simply send the message and add/update row in the messageLog table...
You'll probably want to have some sort of purging process on the log table too
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply