--压缩文件: a 压缩,-ep 从名称中排除路径
declare	@sql nvarchar(200)
set @sql = '"D:\Program Files\WinRAR\WinRAR.exe" a -ep F:\a.rar F:\a.txt'
exec master..xp_cmdshell @sql

--解压文件: e 解压,-o+ 覆盖
declare	@sql nvarchar(200)
set @sql = '"D:\Program Files\WinRAR\WinRAR.exe" e -o+ F:\a.rar F:\'
exec master..xp_cmdshell @sql

--解压文件: e 压缩, -o-跳过,-inul 禁止所有消息。
declare	@sql nvarchar(200)
set @sql = '"D:\Program Files\WinRAR\WinRAR.exe" e -o- -inul F:\a.rar F:\'
exec master..xp_cmdshell @sql



---附:
---xp_cmdshell的启用、禁用
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1 --1为启用,0为禁用
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

 

相关文章:

  • 2021-11-30
  • 2021-12-17
  • 2021-11-05
  • 2022-01-27
猜你喜欢
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2021-06-15
  • 2021-12-08
  • 2022-12-23
  • 2022-02-22
相关资源
相似解决方案