Technical Article

Encrypt DTSRUN command

,

This stored procedure is for encrypting a dtsrun command in order to add it to scheduled job.
Be carfull of adding the /!Y at the end of the dtsrun command.

 

You can change all the declaration values like : varcha(1000) into whatever size you want.

Keep in mind that the encrypted line is quite long.

 

If you have any question feel free the post question on the forum.

I will be glad to help you:)

/*
Encrypt DTSRUN command
*/
CREATE PROCEDURE ENCRYPT_DTS 
@cmd varchar(1000), -- line of the dtsrun command to encrypt with /!Y included in the end
@result varchar(1000) OUTPUT -- return line encrypted
AS
declare @dtscmd varchar(1000)
declare @dtscmdenc varchar(1000)
declare @chaine varchar(1000)

create table #cnt(primary_key int identity(1,1) not null,info varchar(1000))

set @dtscmd = @cmd 

INSERT #cnt(info) exec master..xp_cmdshell @dtscmd

DECLARE @item_category_counter INT
DECLARE @loop_counter INT

SELECT @loop_counter = ISNULL(COUNT(*),0) FROM #cnt

SET @item_category_counter = 1
SET @dtscmdenc = ''

-- getting trough the table
WHILE @loop_counter > 0 AND @item_category_counter < @loop_counter
    BEGIN
        SELECT @chaine = isnull(info,'')
        FROM #cnt
        WHERE primary_key = @item_category_counter

-- concatenate 
SET @dtscmdenc = @dtscmdenc + @chaine

--next line
        SET @item_category_counter = @item_category_counter + 1
    END

SET @result = rtrim(replace(@dtscmdenc,'/!Y',''))

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating