May 24, 2012 at 4:05 am
Hi,
I have a file which I named "file1 codp meta2.rar"
As you can see this file name as spaces betwwen string which makes the below command don't work:
set @NomeFinal ='file1 codp meta2.rar'
set @DirectoriaFinal='c:'
select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''
exec master..xp_cmdshell @cmd, no_output
The execute command only takes part of the name "file1" because of the spaces...
How can I make this work ? the file name shoud have spaces....
May 24, 2012 at 4:28 am
try using double quotes around file name:
set @NomeFinal ='"file1 codp meta2.rar"'
May 24, 2012 at 4:34 am
If I do that. then I have this (below) as the name of the file.
It does not work too..
c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"
May 24, 2012 at 4:38 am
river1 (5/24/2012)
If I do that. then I have this (below) as the name of the file.It does not work too..
c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"
try
"c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"
MVDBA
May 24, 2012 at 4:39 am
is that the full query or is there more after the +'' at the end?
May 24, 2012 at 4:45 am
This is how the command tries to execute:
"C:\Program Files\WinRAR\WinRAR.exe" x -u c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"_Dir\
May 24, 2012 at 4:49 am
river1 (5/24/2012)
This is how the command tries to execute:"C:\Program Files\WinRAR\WinRAR.exe" x -u c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"_Dir\
It's wrong. The whole path should be surrounded by double-quotes:
... -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"
May 24, 2012 at 4:50 am
what is the full query, not the full command as looking at that command, you have missed a load of stuff from the query
set @NomeFinal ='file1 codp meta2.rar'
set @DirectoriaFinal='c:'
select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''..............................................
exec master..xp_cmdshell @cmd, no_output
May 24, 2012 at 5:00 am
full query (still don't work):
set @nomeexacto = (select top 1 s from a1 where s like '%'+@nomeficheiro+'%')
set @DirectoriaFinal = '"'+@caminho+@nomeexacto+'_Dir\"'
set @NomeFinal='"'+@caminho+@nomeexacto+'"'
set @cmd = 'mkdir '+@DirectoriaFinal
exec master..xp_cmdshell @cmd, no_output
select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''
--select @cmd
exec master..xp_cmdshell @cmd, no_output
Result:
"C:\Program Files\WinRAR\WinRAR.exe" x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"
May 24, 2012 at 5:02 am
your command needs to look like
C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"
MVDBA
May 24, 2012 at 5:05 am
From what I saw you just took the " from "C:\Program Files\WinRAR\WinRAR.exe"
but Program Files as a space does it work?
May 24, 2012 at 5:07 am
It's as you told:
C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"
Still does not work....
May 24, 2012 at 5:09 am
what errors do you get as I just run the following in a cmd prompt and it works fine
"c:\program files\winrar\winrar.exe" x -u "c:\users\anthony.green\desktop\deadlock.rar" "c:\users\anthony.green\desktop\deadlock_rar\"
Also run this with no errors
"c:\program files\winrar\winrar.exe" x -u "c:\users\anthony.green\desktop\dead lock.rar" "c:\users\anthony.green\desktop\dead lock_rar\"
May 24, 2012 at 5:18 am
without you telling us the error message i can only assume you don't have winrar command line installed
MVDBA
May 24, 2012 at 5:24 am
river1 (5/24/2012)
It's as you told:C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"
Still does not work....
Is
PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir
a folder name?
Viewing 15 posts - 1 through 15 (of 26 total)
You must be logged in to reply to this topic. Login to reply