Home Forums SQL Server 7,2000 Administration getting error "The system cannot find the path specified." using xp_cmdshell RE: getting error "The system cannot find the path specified." using xp_cmdshell

  • analogue xp_cmdshell

    -----------------------

    MSSQL2000 :

    nothing

    MSSQL2005 :

    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 http://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

    -----------------------

    :hehe: