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.