SendTo 文件夹的 7zip SFX 批处理 [英] 7zip SFX Batch For SendTo Folder
问题描述
7z a -mx9 -sfx %1.exe %1
这是我目前拥有的批处理文件,如果我将文件或文件夹拖放到批处理文件上,我会在 Ultra Compression 上获得与原始文件同名的 7zip SFX.但这仅适用于文件与批处理文件位于同一文件夹中的情况.
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.
我想要实现的是,将此批处理文件放入 sendto 文件夹,以便我可以将任何位置的任何文件转换为高度压缩的 exe,该文件出现在原始目录的文件夹中.
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.
编辑 5 月 29 日 @ 16:50
Edit 29 May @ 16:50
[HKEY_CLASSES_ROOT*shellCompress To Exe]
[HKEY_CLASSES_ROOT*shellCompress To Exe]
[HKEY_CLASSES_ROOT*shellCompress To Execommand]@=""c:Program Files7-Zip7z" u -mx9 -sfx -r -t7z "%1.exe" "%1""
[HKEY_CLASSES_ROOT*shellCompress To Execommand] @=""c:Program Files7-Zip7z" u -mx9 -sfx -r -t7z "%1.exe" "%1""
将其添加到注册表或 .reg 文件以创建上下文菜单按钮,这是 sendto 的父级.
add that to registry or .reg file to create a context menu button, that's parent to the sendto.
推荐答案
我使用以下批处理文件将文件或文件夹发送到 Send-To 快捷方式,这会在与原始文件/文件夹:
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 Files7-Zip7z" u -mx9 -sfx -r -t7z "%~n1.exe" "%~f1"
goto :EOF
:file
cd /d "%~dp1"
if exist "%~n1.exe" (
"c:Program Files7-Zip7z" u -mx9 -sfx -t7z "%~n1_zipped.exe" "%~f1"
) else (
"c:Program Files7-Zip7z" u -mx9 -sfx -t7z "%~n1.exe" "%~f1"
)
goto :EOF
我的参数和你的略有不同,但你可以随意调整.
My parameters are slightly different from yours, but you can tweak them as you like.
添加了ifexist
代码,这样如果你发送一个.exe
到批处理文件,它仍然会创建一个自解压的.exe
code>,但在文件名中带有 _zipped
.
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.
这篇关于SendTo 文件夹的 7zip SFX 批处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!