如何创建自解压的RAR存档,在执行时不显示任何内容? [英] How to create self-extracting RAR archive not showing anything on execution?

查看:154
本文介绍了如何创建自解压的RAR存档,在执行时不显示任何内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个自解压缩的存档,该存档使用WinRar提取到%USERPROFILE%\ Desktop".但是,当我运行它时,它将解压缩到SFX的当前目录,而不是我的桌面. 提取路径选项是否可以正常工作?

I am trying to create a self-extracting archive that extracts to "%USERPROFILE%\Desktop" with WinRar. However, when I run it, it extracts to the SFX's current directory, not my desktop. Does the path to extract option work at all?

我正在使用32位命令行模块.

I'm using the 32-bit command line module.

我还选中了隐藏全部"框,以使其处于静默模式,该框似乎完全不起作用,并且命令提示符窗口仍然出现,其中显示了有关所提取内容的信息.

I also checked the 'hide all' box for silent mode which appears to do absolutely nothing and the command prompt window still appears with showing information on what is extracted.

我希望SFX存档将.exe和SFX文件中包含的文件夹提取到桌面,而不会弹出任何消息.

I want that SFX archive extracts the .exe and the folder contained in the SFX file to the desktop without any messages popping up.

有什么建议吗?

推荐答案

可以创建SFX RAR存档,将所有文件和文件夹直接提取到
"%USERPROFILE%\Desktop"而不显示窗口.

It is possible to create an SFX RAR archive extracting all files and folders directly to
"%USERPROFILE%\Desktop" without showing a window.

在选择文件和文件夹并单击工具栏上的添加图标后,可以使用 WinRAR 完成此操作

This can be done with WinRAR after selecting the files and folders and clicking on icon Add in the toolbar by

  1. 选中常规标签上的选项创建SFX归档文件
  2. 点击按钮 SFX选项上的选项卡高级
  3. 在SFX选项卡常规上输入提取路径字符串"%USERPROFILE%\Desktop",这会自动选择正确的选项绝对路径
  4. 在"SFX"选项卡上选择"模式",然后选择全部隐藏
  5. 在SFX选项卡上选择 Module (模块) SFX模块 Default.sfx (WinRAR GUI SFX模块),
  6. 使用按钮确定,关闭高级SFX选项窗口,
  7. 输入选项卡常规 SFX存档的名称,
  8. 并使用确定按钮开始压缩.
  1. checking on tab General the option Create SFX archive,
  2. clicking on tab Advanced on button SFX options,
  3. entering on SFX tab General for Path to extract the string "%USERPROFILE%\Desktop" which results in automatic selection of option Absolute path which is right,
  4. selecting on SFX tab Modes the option Hide all,
  5. selecting on SFX tab Module the SFX module Default.sfx (WinRAR GUI SFX module),
  6. closing Advanced SFX options window with button OK,
  7. entering on tab General the name for the SFX archive,
  8. and starting compression with button OK.

如果将模块 WinCon.sfx 用于SFX存档,将始终显示命令提示符窗口,因为在这种情况下,Windows在SFX存档启动时自动检测到这是一个控制台应用程序并打开在其中执行控制台SFX的命令提示符窗口.

A command prompt window will be always displayed if module WinCon.sfx is used for the SFX archive as in this case Windows detects automatically on start of the SFX archive that this is a console application and opens a command prompt window in which the console SFX is executed.

也可以使用批处理文件来创建这样的SFX存档:

Creating such an SFX archive can be done also with a batch file:

@echo off
echo ;The comment below contains SFX script commands>"%TEMP%\SfxOptions.txt"
echo/>>"%TEMP%\SfxOptions.txt"
echo Path="%%USERPROFILE%%\Desktop">>"%TEMP%\SfxOptions.txt"
echo Silent=^1>>"%TEMP%\SfxOptions.txt"
"%ProgramFiles%\WinRAR\Rar.exe" a -c -cfg- -ep1 -idq -m5 -mdg -r -s -sfx -y "-z%TEMP%\SfxOptions.txt" "Path\Name of your SFX.exe" "Path\Folder to add" "Path\File to add"
if errorlevel 1 goto Failure
del "%TEMP%\SfxOptions.txt"
goto :EOF

:Failure
del "%TEMP%\SfxOptions.txt"
echo/
echo Error on creation of "Path\Name of your SFX.exe"
echo/
pause

在此批处理文件中,必须对其进行修改以供使用:

In this batch file must be modified for usage:

  1. 指向 WinRAR 的程序文件文件夹的路径,其中包含控制台版本Rar.exe以及SFX模块 Default.sfx .
  2. 要创建的SFX存档的路径和名称.
  3. 要添加到存档中的文件夹和/或文件的路径和名称.
  1. Path to program files folder of WinRAR containing console version Rar.exe and also the SFX module Default.sfx.
  2. Path and name of the SFX archive to create.
  3. Path and name of folder and/or file to add to the archive.

使用的开关在 WinRAR 的程序文件文件夹中的文本文件 Rar.txt 中进行了说明.

The used switches are explained in text file Rar.txt in program files folder of WinRAR.

关于开关-ep1的另一注:

将文件夹或文件添加到存档中时,要添加到存档中的文件夹和/或文件名中的最后一个反斜杠将从名称中删除.

Everything up to last backslash in name of folder and/or file to add to archive is removed from name on adding the folder or file to the archive.

在将文件夹添加到RAR存档时,如果指定的文件夹末尾带有反斜杠,则有所不同.

On adding a folder to a RAR archive it makes a difference if the folder is specified with or without a backslash at end.

示例:

像这样的目录树

  • C:\ Temp
    • 我的文件夹
      • 子文件夹1
      • 子文件夹2
        • 文件X
        • C:\Temp
          • MyFolder
            • Subfolder 1
            • Subfolder 2
              • File X

              被压缩

              Rar.exe a -ep1 -r C:\Temp\Demo1.rar C:\Temp\MyFolder
              

              在存档C:\Temp\Demo1.rar

              • 我的文件夹
                • 子文件夹1
                • 子文件夹2
                  • 文件X
                  • MyFolder
                    • Subfolder 1
                    • Subfolder 2
                      • File X

                      使用时

                      Rar.exe a -ep1 -r C:\Temp\Demo2.rar C:\Temp\MyFolder\
                      

                      或使用

                      Rar.exe a -ep1 -r C:\Temp\Demo2.rar C:\Temp\MyFolder\*
                      

                      导致归档文件C:\Temp\Demo2.rar

                      • 子文件夹1
                      • 子文件夹2
                        • 文件X
                        • Subfolder 1
                        • Subfolder 2
                          • File X

                          这篇关于如何创建自解压的RAR存档,在执行时不显示任何内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆