Форум программистов CODEBY.NET Хостинг в Беларуси — Active Technologies

Разработка бизнес сайтов

Нужны клиенты? Тогда сюда быстрее...
X   Сообщение сайта
(Сообщение закроется через 2 секунды)

Здравствуйте, гость ( Вход | Регистрация )




> Простая замена для Xp_cmdshell
alex2345
Вставить ник
сообщение 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
 
Новая тема 
Ответов (1 - 4)
European
Вставить ник
сообщение 31:01:2008, 13:33
Цитата Ответить 


Божественный
*****

Группа: Модеры
Сообщений: 1 816
Регистрация: 4:09:2006
Из: Минск
Пользователь №: 6 316
Специализация: C++



Репутация: - 31 +


Хвастаешься?
Подняться вверх 
 
Сообщение #2
sax_ol
Вставить ник
сообщение 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
alex2345
Вставить ник
сообщение 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
alex2345
Вставить ник
сообщение 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


Быстрый ответ  Ответить  Новая тема 

> Быстрый ответ
Полужирный
Курсив
Подчеркнутый
Вставить изображение
Смайлики
Цитата
Код
 
 Отправлять уведомления об ответах на e-mail |  Включить смайлики |  Добавить подпись
   

 

RSS Текстовая версия Сейчас: 17:05:2008 - 03:57
с нами можно связаться по:
телефону: +375-(29)-632-60-67
e-mail:info@codeby.net