【发布时间】:2018-10-31 07:05:57
【问题描述】:
当我如下调用 xp_cmdshell 时,7z.exe 实际运行,并且它的输出是正确的,因为没有包含参数:
declare @Command VARCHAR(1000)
set @Command = '"C:\Program Files\7-Zip\7z.exe" a '
exec master..xp_cmdshell @command
select @Command
输出:
output
NULL
7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
NULL
NULL
NULL
Command Line Error:
Cannot find archive name
NULL
添加文件后,我得到一个完全不同的错误:7z.exe is not found:
declare @Command VARCHAR(1000)
set @Command = '"C:\Program Files\7-Zip\7z.exe" a ' + '"' + 'C:\TO_ERASE\ToZip.txt' + '"'
exec master..xp_cmdshell @command
select @Command
输出:
output
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
NULL
问题可能是什么?
唯一的区别是我添加了文件名作为参数。如果7z.exe 产生错误,我会理解,但Windows 没有找到exe 文件。
【问题讨论】:
标签: sql-server-2008 tsql windows-server-2008