什么是可执行文件?可执行文件是可以运行的程序文件,带有一组指令或选项以使其在您的 PC 上执行某些操作。几乎所有现代操作系统上都可以找到可执行文件,但大多数人会将它们与Windows EXE文件格式相关联。
当您在使用EXE(EXE)扩展名的 PC 上安装新软件(install new software)或运行程序时,您通常会看到一个EXE文件。如果您正在创建自己的软件,您甚至可以创建自己的可执行文件来运行、安装或分发。如果您有兴趣了解有关可执行文件以及如何创建可执行文件的更多信息,请执行以下操作。
可执行 (EXE) 文件的风险(The Risks Of Executable (EXE) Files)
当您运行一个可执行文件时,您授予它运行其中包含的指令的权限。这就是任何软件的工作方式,从基本的几行脚本到具有数百万行代码的复杂软件。
在运行或制作可执行文件之前,您应该意识到潜在的风险。可执行文件有可能在源代码(source code)中包含可能损坏您的 PC 的指令。
它可以告诉您的 PC 删除其他文件,或者它可以指示您的 PC 将信息发送到外部来源。这是恶意软件(malware)的定义,其目的是造成损害,损害您的利益。
在运行任何可执行文件之前,尤其是当它在用户帐户控制弹出窗口中要求管理权限时,您应该使用Windows 安全(Windows Security)性或您自己的第三方反恶意软件(如 Malwarebytes(third-party anti-malware software like Malwarebytes) )扫描文件以查找恶意软件。您还应该只安装或运行来自您绝对(absolutely)信任的来源的软件。
如果您正在创建自己的软件来运行,您应该确保代码不是为访问任何重要文件而设计的。虽然Windows通常会使用UAC阻止对系统文件的未经授权的访问,但请在运行之前仔细检查您的代码,以确保该软件不会损害您的 PC。
在 Windows 上打开可执行 (EXE) 文件(Opening Executable (EXE) Files On Windows)
如果你想在Windows上打开一个可执行文件,你可以通过几种方式来实现。Windows自动将EXE文件格式识别为可执行文件,因此您通常可以从桌面、Windows 文件资源管理器(Windows File Explorer)、使用Windows 开始(Windows Start)菜单(对于已安装的软件)或使用运行(Run)命令框打开它。
- 要在桌面或Windows 文件资源管理器(Windows File Explorer)中打开EXE文件,请双击该文件。这将指示Windows打开它。
- Windows 开始(Windows Start)菜单中的已安装软件列表是这些软件的EXE文件的快捷方式(例如, Google Chrome 的Chrome.exe)。按开始菜单(Start menu) 图标(icon)(或按键盘上的Windows 键(Windows key)),然后按其中一个条目运行您的软件。
- 要使用运行(Run)命令框运行EXE文件,请按键盘上的Windows key + R 或者,右键单击“开始”菜单图标(Start menu icon),然后按“运行”(Run)选项。
- 在“运行”(Run)命令框中,通过按“浏览(Browse)”找到可执行文件,或直接键入文件位置。当您要运行EXE文件时,请按OK。
- 如果EXE文件请求管理访问权限,您需要允许它在UAC弹出窗口中运行。按是(Yes)允许这样做。
- 如果可执行文件无法运行(例如,它可能是为旧版本的Windows设计的),那么Windows将阻止它运行。您可能还会看到一条错误消息。如果发生这种情况,请按关闭(Close)并查找要运行的文件的替代版本。
如何在 Windows 上创建可执行文件(How To Create An Executable File On Windows)
如果你想在Windows(Windows)上创建自己的可执行文件,你可以,但它并不像重命名文件并在文件末尾添加.exe那样简单。
您需要使用您选择的编程语言编写要运行的软件,然后将其编译为可以执行的文件。然而,大多数用户希望创建更多基本的可执行文件,例如用于软件安装的安装程序文件。
您可以在Windows(Windows)上使用内置的IExpress 向导(IExpress Wizard)来执行此操作,但该软件非常旧,并且已经有一段时间没有更新了。更好的选择是使用开源Inno Setup,或者,对于基本的自解压EXE文件,您可以使用7-Zip。
使用 7-Zip 创建的EXE文件实际上是一个SFX 存档文件(SFX archive file)。此存档文件以EXE文件格式出现,会自动将任何包含的文件提取到您的 PC 上,非常适合简单的软件部署。
如果您想与多个用户共享文件而不必担心他们安装了正确的软件,那么创建这样的文件将是一个不错的选择。
- 要使用 7-ZIP 创建EXE文件,请将文件放在Windows 文件资源管理器(Windows File Explorer)中的文件夹中。右键单击(Right-click)该文件夹,然后按7Zip > Add to archive.
- 在选项(Options)框中,单击启用 SFX 存档(Enable SFX Archive )复选框。您还需要将Archive Format设置为7z,将Compression Method设置为LZMA2,并将Compression Level设置为Normal。按确定(OK)创建文件。
虽然这不是一个真正的EXE文件,但它的外观和行为都像一个文件,使其成为一种创建可执行文件的简单方法,该文件可以分发您与他人一起创建的软件或文件。
否则,如果你想创建一个“真正的”可执行文件,你需要学习如何编程(learn how to program).
在 Mac 或 Linux 上运行可执行文件(Running Executable Files On Mac Or Linux)
可执行文件在Windows上的运行方式与程序在其他平台(如Linux或 macOS)上的运行方式完全不同。这些平台确实有可执行文件,但它们不是EXE文件格式。
例如,在Linux上,任何文件都可以是可执行的,但它需要一个特殊的文件权限标志才能使用(Linux)chmod作为程序运行。例如,命令chmod +x file 将赋予名为file的文件运行的执行权限。
macOS 运行软件的方法略有不同。如果该应用程序尚未从App Store安装,并且它不是来自它认识或信任的开发者,则该应用程序将不会被允许运行。您需要在System Preferences > Security & Privacy 菜单中允许它。
然而,作为一个基于 Unix 的系统,macOS 确实支持chmod命令,允许您使用终端(Terminal)应用程序执行更基本的脚本。例如,如果您开发了Python脚本,则可以使用chmod +x 命令来运行它。
您还可以使用适用于Linux和 macOS的WINE模拟器在这些平台上运行和安装 Windows EXE 文件。(run and install Windows EXE files)旨在模拟某些Windows指令和库,使用WINE运行EXE文件将取得不同程度的成功。
您可以通过查看WineHQ 数据库(WineHQ database)来确认使用WINE运行流行软件的效果如何。
在 Windows 10 上运行可执行文件(Running Executable Files On Windows 10)
没有什么能阻止您创建自己的软件,尤其是当您将它与Windows 安装程序包(Windows installer packages)结合使用以使其易于安装时。然而,对于大多数 Windows 10 用户来说,EXE文件是用来运行的,而不是制作的。只要您只从您信任的来源运行软件,可执行文件就应该是相对安全的。
确保(Make)您定期运行恶意软件扫描,如果您确实不确定可执行文件是否可以安全运行,您可以使用Windows 10 沙盒模式(Windows 10 sandbox mode)在隔离容器中运行软件以对其进行测试。如果EXE是危险的,它不会损坏您的主要Windows安装。
What Is An Executable File & How To Create One
What is an executable file? An еxecutable file is a program file thаt can be run, with a set of instructions or options tо make it do something on your PС. Executable files are found on almost аll modern operating syѕtems, but most рeople will associate them with the Windows EXE file format.
You’ll usually see an EXE file when you install new software or run a program on your PC, where the EXE extension is used. If you’re creating your own software, you can even create your own executable file to run, install, or distribute. If you’re interested in learning more about executable files and how to create an executable file, here’s what you need to do.
The Risks Of Executable (EXE) Files
When you run an executable file, you give it permission to run the instructions held within it. That’s how any software works, from basic few-line scripts to complex software with millions of lines of code.
Before you run or make an executable file, you should be aware of the potential risks. Executable files have the potential to include instructions within the source code that could damage your PC.
It could tell your PC to delete other files, or it could instruct your PC to send information to an outside source. This is the definition of malware, created to cause harm at your expense.
Before you run any executable file, especially if it asks for administrative permissions in a User Account Control pop-up, you should scan the file for malware using Windows Security or your own third-party anti-malware software like Malwarebytes. You should also only install or run software from sources you absolutely trust.
If you’re creating your own software to run, you should make sure that the code isn’t designed to access any important files. While Windows will typically prevent unauthorized access to system files using UAC, double-check your code before you run it to make sure the software can’t harm your PC.
Opening Executable (EXE) Files On Windows
If you want to open an executable file on Windows, you can do so in a few ways. Windows automatically recognizes the EXE file format as an executable file, so you can typically open it from your desktop, from Windows File Explorer, using the Windows Start menu (for installed software), or by using the Run command box.
- To open EXE files on your desktop or in Windows File Explorer, double-click on the file. This will instruct Windows to open it.
- The list of installed software in the Windows Start menu are shortcuts to the EXE files for those software (for instance, Chrome.exe for Google Chrome). Press the Start menu icon (or hit the Windows key on your keyboard), then press one of the entries to run your software.
- To use the Run command box to run an EXE file, press the Windows key + R on your keyboard. Alternatively, right-click the Start menu icon and press the Run option.
- In the Run command box, locate your executable file by pressing Browse, or type the file location directly. When you want to run the EXE file, press OK.
- If the EXE file requests administrative access, you’ll need to allow it to run in the UAC pop-up. Press Yes to allow this.
- If the executable file can’t run (it may be designed for an older version of Windows, for instance), then Windows will stop it from running. You may also see an error message. If this happens, press Close and look for an alternative version of the file to run instead.
How To Create An Executable File On Windows
If you want to create your own executable files on Windows, you can, but it isn’t as simple as renaming a file and adding .exe to the end of it.
You’ll need to code the software you want to run in your chosen programming language, then compile it as a file that can be executed. Most users will want to create more basic executable files, however, such as installer files for software installations.
You could use the built-in IExpress Wizard to do this on Windows, but this software is very old and hasn’t been updated in some time. The better option is to use the open-source Inno Setup or, for basic self-extracting EXE files, you could use 7-Zip.
An EXE file created using 7-Zip is actually an SFX archive file. This archive file, appearing with the EXE file format, will automatically extract any included files onto your PC, making it perfect for simple software deployments.
If you want to share files to multiple users without having to worry about them having the right software installed, creating a file like this would be a good option.
- To create an EXE file using 7-ZIP, place your files in a folder in Windows File Explorer. Right-click the folder, then press 7Zip > Add to archive.
- In the Options box, click the Enable SFX Archive checkbox. You’ll also want to set the Archive Format to 7z, the Compression Method to LZMA2, and the Compression Level to Normal. Press OK to create the file.
While this isn’t a true EXE file, it looks and acts like one, making it an easy way to create an executable file that can distribute software or files you’ve created with others.
Otherwise, if you want to create a “real” executable file, you’ll need to learn how to program.
Running Executable Files On Mac Or Linux
The way executable files work on Windows is entirely different to the way that programs run on other platforms, like Linux or macOS. These platforms do have executable files, but they aren’t in the EXE file format.
On Linux, for instance, any file can be executable, but it requires a special file permissions flag to run it as a program using chmod. The command chmod +x file would give a file named file the execute permission to run, for instance.
macOS has a slightly different method for running software. If the app hasn’t been installed from the App Store, and it isn’t from a developer it knows or trusts, then the app won’t be allowed to run. You’ll need to allow it in your System Preferences > Security & Privacy menu.
As a Unix-based system, however, macOS does support the chmod command, allowing you to execute more basic scripts using the Terminal app. If you developed a Python script, for instance, you could use the chmod +x command to run it.
You can also use the WINE emulator for Linux and macOS to run and install Windows EXE files on those platforms. Designed to emulate certain Windows instructions and libraries, using WINE to run an EXE file will have varying levels of success.
You can confirm how well popular software will run using WINE by checking the WineHQ database.
Running Executable Files On Windows 10
There’s nothing stopping you creating your own software, especially if you combine it with Windows installer packages to make it easy to install. For most Windows 10 users, however, EXE files are there to be run, not made. As long as you only run software from sources you trust, executable files should be relatively safe.
Make sure that you run malware scans regularly and, if you’re really unsure about whether an executable file is safe to run, you can use the Windows 10 sandbox mode to run software in an isolated container to test it out. If the EXE is dangerous, it won’t damage your main Windows installation.