Помощник
Здравствуйте, гость ( Вход | Регистрация )
|
|
31:01:2008, 13:29
|
|
Новенький ![]() Группа: Программист Сообщений: 3 Регистрация: 31:01:2008 Пользователь №: 15 109 Специализация: SQL Репутация: 0
|
Простая замена для xp_cmdshell
С возможностью раздачи прав на доступ. Код declare @iShl int, @iStm int, @iStdOut int, @iLine int, @hr int, @EndOfStream int,
@strText nvarchar(4000), @cmd nvarchar(4000) set @cmd = 'Exec("cmd /c ping -n 3 -w 1000 www.ru")' EXEC @hr = sp_OACreate 'Wscript.Shell', @iShl OUT EXEC @hr = sp_OAMethod @iShl, @cmd, @iStm out EXEC @hr = sp_OAGetProperty @iStm, 'StdOut', @iStdOut out EXEC @hr = sp_OAGetProperty @iStdOut, 'AtEndOfStream', @EndOfStream out WHILE @EndOfStream = 0 BEGIN EXEC @hr = sp_OAGetProperty @iStdOut, 'ReadLine', @strText out print @strText EXEC @hr = sp_OAGetProperty @iStdOut, 'AtEndOfStream', @EndOfStream out END EXEC @hr = sp_OADestroy @iShl Сообщение отредактировал European - 31:01:2008, 13:33 |
|
Сообщение
#1
|
|
![]() |
|
|
31:01:2008, 13:33
|
|
Божественный ![]() ![]() ![]() ![]() ![]() Группа: Модеры Сообщений: 1 816 Регистрация: 4:09:2006 Из: Минск Пользователь №: 6 316 Специализация: C++ Репутация: 31
|
Хвастаешься?
|
|
Сообщение
#2
|
|
|
|
31:01:2008, 13:38
|
|
============== ![]() ![]() ![]() ![]() ![]() Группа: Модеры Сообщений: 1 740 Регистрация: 11:01:2007 Пользователь №: 8 750 Специализация: specialist Репутация: 27
|
чето эта, сильно не разбираслся вкинул на выполнение и вот
Цитата Msg 15281, Level 16, State 1, Procedure sp_OACreate, Line 1 SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. Msg 15281, Level 16, State 1, Procedure sp_OAMethod, Line 1 SQL Server blocked access to procedure 'sys.sp_OAMethod' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. Msg 15281, Level 16, State 1, Procedure sp_OAGetProperty, Line 1 SQL Server blocked access to procedure 'sys.sp_OAGetProperty' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. Msg 15281, Level 16, State 1, Procedure sp_OAGetProperty, Line 1 SQL Server blocked access to procedure 'sys.sp_OAGetProperty' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. Msg 15281, Level 16, State 1, Procedure sp_OADestroy, Line 1 SQL Server blocked access to procedure 'sys.sp_OADestroy' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online. PS: я к тому что надо пояснять заранее |
|
Сообщение
#3
|
|
|
|
1:02:2008, 07:54
|
|
Новенький ![]() Группа: Программист Сообщений: 3 Регистрация: 31:01:2008 Пользователь №: 15 109 Специализация: SQL Репутация: 0
|
Sorry,
тестировал на SQL 2000. Там всё работает без дополнительных настроек. В SQL 2005 нужно выполнить: Код sp_configure 'show advanced options', 1;
GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO Сообщение отредактировал European - 1:02:2008, 08:32 |
|
Сообщение
#4
|
|
|
|
8:02:2008, 10:39
|
|
Новенький ![]() Группа: Программист Сообщений: 3 Регистрация: 31:01:2008 Пользователь №: 15 109 Специализация: SQL Репутация: 0
|
analogue xp_cmdshell
замена для xp_cmdshell --------------------------------------------------------------------- Windows 2000: need Windows Script 5.6 for Windows XP and Windows 2000 Windows 2003: included --------------------------------------------------------------------- MSSQL2000 : nothing, Ole Automation Procedures enabled MSSQL2005 : Код sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO MSSQL2008 : [url=http://msdn2.microsoft.com/en-us/library/ms191188(SQL.100).aspx]http://msdn2.microsoft.com/en-us/library/m...8(SQL.100).aspx[/url] sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO --------------------------------------------------------------------- declare @iShl int, @iStm int, @iStdOut int, @hr int, @EndOfStream int, @strText nvarchar(4000), @cmd nvarchar(4000) set @cmd = 'Exec("cmd /c ping -n 3 -w 1000 127.0.0.1")' EXEC @hr = sp_OACreate 'Wscript.Shell', @iShl out EXEC @hr = sp_OAMethod @iShl, @cmd, @iStm out EXEC @hr = sp_OAGetProperty @iStm, 'StdOut', @iStdOut out EXEC @hr = sp_OAGetProperty @iStdOut, 'AtEndOfStream', @EndOfStream out WHILE @EndOfStream = 0 BEGIN EXEC @hr = sp_OAGetProperty @iStdOut, 'ReadLine', @strText out print @strText EXEC @hr = sp_OAGetProperty @iStdOut, 'AtEndOfStream', @EndOfStream out END EXEC @hr = sp_OADestroy @iShl --------------------------------------------------------------------- Keywords: xp_cmdshell, faq, howto, problem, error, alternative, command line, cmd проблема, как обойти, ошибка --------------------------------------------------------------------- Модератор:Не забывайте про оформление поста! |
|
Сообщение
#5
|
|
![]() |
|
Текстовая версия | Сейчас: 17:05:2008 - 03:57 |