Creating a zip file with SQL Server

Here is the code I use to create a .rarpassword file

DECLARE @source VARCHAR(1000),
        @destination VARCHAR(1000),
        @Command VARCHAR(1000)

SET @source = 'E:\Temp\testRar.txt'
SET @destination = 'E:\Temp\testRar.rar'

SET @Command = '"C:\Program Files\WinRAR\Rar.exe"  a -ep1 -pasd^ad ' +@destination+' '+@source

EXEC MASTER..xp_cmdshell @Command

but it sets a password asdad, and the character asd^adis ^ignored. Why?

+4
source share
2 answers

The ^ character is an escape character in the shell. Try to double it.

SET @Command = '"C:\Program Files\WinRAR\Rar.exe"  a -ep1 -pasd^^ad ' +@destination+' '+@source
+2
source

I have a small question: what password is specified in the sentence "C: \ Program Files \ WinRAR \ Rar.exe" and -ep1 -pasd "^" ad?

0
source

All Articles