2
7z a -mx9 -sfx %1.exe %1

This is what i have so far as a batch file, which if i drag and drop a file or folder onto the batch file i get a 7zip SFX on Ultra Compression under the same name as the original file. but this only works if the file is in the same folder as the batch file.

What im trying to achieve is, putting this batch file into the sendto folder so i can convert any file anywhere into a highly compressed exe, which appear in the folder of the original directory.

Any help would be greatly appreciated, im sure its simple but i haven't a clue.

Edit 29 May @ 16:50

[HKEY_CLASSES_ROOT*\shell\Compress To Exe]

[HKEY_CLASSES_ROOT*\shell\Compress To Exe\command] @="\"c:\Program Files\7-Zip\7z\" u -mx9 -sfx -r -t7z \"%1.exe\" \"%1\""

add that to registry or .reg file to create a context menu button, that's parent to the sendto.

4

1 回答 1

2

我使用以下批处理文件将文件或文件夹发送到 Send-To 快捷方式,该快捷方式会在与原始文件/文件夹相同的位置创建一个自解压 7z 文件:

@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

我的参数与你的略有不同,但你可以随意调整它们。

5 月 29 日 - 编辑

添加了if exist代码,以便如果您向.exe批处理文件发送一个,它仍然会创建一个自解压的.exe,但_zipped在文件名中带有。

于 2013-05-29T03:03:42.907 回答