sql语句:
declare @p1 nvarchar(4000)
declare @outpath nvarchar(4000)
select @p1='D:\145.xls'
select @outpath='D:\test123.rar'
declare @cmd nvarchar(4000)
select @cmd='""%ProgramFiles%\WinRAR\Rar.exe"" a -ep1 '+@outpath+' '+@p1
exec master..xp_cmdshell @cmd
asp语句:
//WriteLn(aFiles);
var xlsurl = "./output/bidding/" + (Session.SessionId+"."+NOW.valueOf()) + ".rar";
var sql = "declare @cmd nvarchar(4000)"
+ " select @cmd='\"\"%ProgramFiles(x86)%\\WinRAR\\Rar.exe\"\" a -ep1 "+Server.MapPath(xlsurl)+" "+aFiles.join(" ")+"'"
+ " exec master..xp_cmdshell @cmd";
//WriteLn(sql);
oConn.Execute(sql);
Response.Redirect(xlsurl);