Following is the Trigger
create trigger runexe
on tbDetails
for insert
As
Begin
print 'Inserted'
Exec Master..xp_cmdshell 'E:\Hiran\Alarm.exe'
End
Some SQL Server versions does not allowed to run the "xp_cmdshell" command. In that case you have to enable that feature by executing the following commands.
EXEC sp_configure ‘show advanced options’, 1
EXEC sp_configure ‘xp_cmdshell’, 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using System.Security;
namespace Alarm
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
System.Diagnostics.Process.Start("cmd.exe", @"/c E:\Hiran\aaa.bat");
Application.Exit();
}
}
}
Then open the notepad and write the below cording. After that save it using .bat extension.
sndrec32 /play /close "E:\Hiran\SirenSound.wav"
Now You are done. Please comment if you need any help.
Thank You.
Working perfectly. Really interesting post.
ReplyDelete