sql 触发器触发外部程序
xp_cmdshell 我使用过.不成功.不能成功调用此程序。
我简单分析了一下.应该是在mssql 线程空间不允许有其它 进程
我现在还有什么办法能触发外部程序
期待有人帮一下
[最优解释]
CLR....
[其他解释]
结帖率:100.00% 都没人顶一下。。真伤心
[其他解释]
?要看是怎的操作
xp_cmdshell--用的句是SQL Server操作,是系操作?
[其他解释]
Exec xp_cmdshell 'E:\debug\DBToIM.exe'
这个程序(DBToIM.exe)的作用是登陆openfire 然后发信息
但运行没有结果。
而我双击运行时是可以正常运行的。
通过xp_cmdshell 就失效了
[其他解释]
该回复于2010-12-03 11:48:20被版主删除
[其他解释]
http://community.kingdee.com/pages/dcyang/blog/archive/2009/12/12/391640.aspx
[其他解释]
是不行的,不可以在器里用windows程序
主可用CLR器
[其他解释]
Exec xp_cmdshell 'Start E:\debug\DBToIM.exe'
是一下这个
[其他解释]
楼上的呢
xp_cmdshell 'dir *.exe'
这个在mssql 的线程中是安全的。
而我的程序mssql 不会确认是绝对安全的。会影响 mssql 程序的运行。
所以mssql 执行xp_cmdshell 调用我的程序。应该做了处理。不会正常运行结果
而ls 所讲的帮助文档我看过了。 我确认我也会使用这个命令。你有可以的话可以试试自己写个程序。这个程序 可以开个线程 去做些事情。然后你可以 在触发器中调用这个函数。你看看会不会有一些效果。
谢谢你的帮助。
[其他解释]
Exec xp_cmdshell 'start E:\debug\DBToIM.exe'
不可以
[其他解释]
to wxf163
(小小菜)
你可以这样试试看。看看自己点击这个程序和 触发器运行这个程序。计算机的反应
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport ( "user32.dll", EntryPoint = "FindWindow", SetLastError = true )]
private static extern IntPtr FindWindow( string lpClassName, string lpWindowName );
[DllImport ( "user32.dll", EntryPoint = "FindWindowEx", SetLastError = true )]
private static extern IntPtr FindWindowEx( IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow );
[DllImport ( "user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto )]
private static extern int SendMessage( IntPtr hwnd, uint wMsg, int wParam, int lParam );
[DllImport ( "user32.dll", EntryPoint = "SetForegroundWindow", SetLastError = true )]
private static extern void SetForegroundWindow( IntPtr hwnd );
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
const uint BM_CLICK = 0xF5; //鼠标点击的消息,对于各种消息的数值,API手册
IntPtr hwndCalc = FindWindow ( null, "计算器" ); //查找计算器的句柄
if ( hwndCalc != IntPtr.Zero )
{
IntPtr hwndThree = FindWindowEx ( hwndCalc, 0, null, "3" ); //获取按钮3 的句柄
IntPtr hwndPlus = FindWindowEx ( hwndCalc, 0, null, "+" ); //获取按钮 + 的句柄
IntPtr hwndTwo = FindWindowEx ( hwndCalc, 0, null, "2" ); //获取按钮2 的句柄
IntPtr hwndEqual = FindWindowEx ( hwndCalc, 0, null, "=" ); //获取按钮= 的句柄
SetForegroundWindow ( hwndCalc ); //将计算器设为当前活动窗口
System.Threading.Thread.Sleep ( 2000 ); //暂停2秒
SendMessage ( hwndThree, BM_CLICK, 0, 0 );
System.Threading.Thread.Sleep ( 2000 ); //暂停2秒
SendMessage ( hwndPlus, BM_CLICK, 0, 0 );
System.Threading.Thread.Sleep ( 2000 ); //暂停2秒
SendMessage ( hwndTwo, BM_CLICK, 0, 0 );
System.Threading.Thread.Sleep ( 2000 ); //暂停2秒
SendMessage ( hwndEqual, BM_CLICK, 0, 0 );
System.Threading.Thread.Sleep ( 2000 );
}
else
{
}
}
------其他解决方案--------------------
实在不懂c++哦美女
[其他解释]
实在不懂c++哦美女
[其他解释]
是这样的。最后采用管道在两进程通信解决些问题。
谢谢大家。 以后有人遇到些问题。请参考管道通信
[其他解释]
xp_cmdshell只能调用bat com之类的控制台应用程序,无法调用exe所以,执行不成功!