7zip SFX Batch For SendTo Folder

独自空忆成欢 提交于 2019-12-06 09:41:41

I use the following batch file to send a file or a folder to the Send-To shortcut, which creates a self extracting 7z file in the same location as the original file/folder:

@echo off
cd /d %1
if %errorlevel%==1 (goto file) else (goto dir)

:dir
cd..
"c:\Program Files\7-Zip\7z" u -mx9 -sfx -r -t7z "%~n1.exe" "%~f1"
goto :EOF

:file
cd /d "%~dp1"
if exist "%~n1.exe" (
  "c:\Program Files\7-Zip\7z" u -mx9 -sfx -t7z "%~n1_zipped.exe" "%~f1"
) else (
  "c:\Program Files\7-Zip\7z" u -mx9 -sfx -t7z "%~n1.exe" "%~f1"
)
goto :EOF

My parameters are slightly different from yours, but you can tweak them as you like.

May 29 - Edit

Added the if exist code so that if you send an .exe to the batch file, it will still create a self-extracting .exe, but with _zipped in the filename.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!