WinApps在Linux中运行Windows应用程序

在 GNU/Linux 上使用 KDE PlasmaGNOMEXFCE 运行 Windows 应用程序(包括 Microsoft 365Adobe Creative Cloud),无缝集成,就像它们是操作系统原生的一样。

底层机制

WinApps 的工作原理如下:

  1. DockerPodmanlibvirt 虚拟机中运行 Windows。
  2. 查询 Windows 中所有已安装的应用程序。
  3. 在主机 GNU/Linux 操作系统上为选定的 Windows 应用程序创建快捷方式。
  4. 使用 FreeRDP 作为后端,无缝渲染 Windows 应用程序和 GNU/Linux 应用程序。

附加功能

  • 在 Windows 中,可以通过 \\tsclient\home 挂载访问 GNU/Linux /home 目录。
  • Nautilus 集成,允许您右键单击文件,并根据文件 MIME 类型使用特定的 Windows 应用程序打开它们。
  • 官方任务栏小部件 可无缝管理 Windows 子系统,并提供一种轻松启动 Windows 应用程序的方法。
  • 来自主机系统的 Microsoft Office 链接(例如 ms-word://)会自动在 Windows 子系统中打开。(注意:您可能需要使用 用户代理切换器 浏览器扩展程序并将用户代理设置为 Windows,因为 Office Web 应用通常会对 Linux 用户隐藏“在桌面应用程序中打开”选项。)

支持的应用程序

WinApps 支持所有个 Windows 应用程序。

通用应用程序支持通过以下方式实现:

  1. 扫描 Windows 系统中是否存在任何官方支持的应用程序(列表如下)。
  2. 扫描 Windows 系统中是否存在 Windows 注册表中列出的任何其他 .exe 文件。

官方支持的应用程序拥有高分辨率图标和预填充的 MIME 类型。这使得文件管理器能够根据文件扩展名确定哪些 Windows 应用程序应该打开文件。检测到的其他应用程序的图标则从 .exe 文件中提取。

我们鼓励您通过提交 Pull 请求来丰富支持的应用程序列表!请帮助我们壮大 WinApps 社区。

请注意,所提供的官方支持应用程序列表是由社区驱动的。因此,某些应用程序可能未经 WinApps 团队测试和验证。

官方支持的应用程序

Adobe Acrobat Pro
(X)
Icon in the Public Domain.
Adobe After Effects
(CC)
Icon in the Public Domain.
Adobe Audition
(CC)
Icon in the Public Domain.
Adobe Bridge
(CS6, CC)
Icon in the Public Domain.
Adobe Creative Cloud
(CC)
Icon under MIT license.
Adobe Illustrator
(CC)
Icon in the Public Domain.
Adobe InDesign
(CC)
Icon in the Public Domain.
Adobe Lightroom
(CC)
Icon in the Public Domain.
Adobe Photoshop
(CS6, CC, 2022)
Icon in the Public Domain.
Command Prompt
(cmd.exe)
Icon under MIT license.
File Explorer
(Windows Explorer)
Icon in the Public Domain.
Internet Explorer
(11)
Icon in the Public Domain.
Microsoft Access
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft Excel
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft Word
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft OneNote
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft Outlook
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft PowerPoint
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft Publisher
(2016, 2019, o365)
Icon in the Public Domain.
Microsoft Visio
(Standard/Pro. 2021, Plan 2)
Icon in the Public Domain.
Microsoft Project
(Standard/Pro. 2021, Plan 3/5)
Icon in the Public Domain.
Microsoft Visual Studio
(Comm./Pro./Ent. 2022)
Icon in the Public Domain.
mIRC
Icon in the Public Domain.
PowerShell
Icon under MIT license.
Windows
(Full RDP Session)
Icon in the Public Domain.

安装

步骤 1:配置 Windows 虚拟机

推荐使用 Docker 和 Podman 后端来运行 Windows 虚拟机,因为它们有助于实现 Windows 的自动化安装过程。WinApps 也兼容 libvirt。虽然此方法需要大量的手动配置,但它也提供了更丰富的虚拟机自定义选项。这三种方法都利用了 KVM 虚拟机管理程序,确保了卓越的虚拟机性能。最终,后端的选择取决于您的具体用例。

以下指南可供参考:

如果您已经拥有希望与 WinApps 一起使用的 Windows 虚拟机或服务器,您仍然需要遵循 libvirt 文档中描述的最终步骤](docs/libvirt.md#final-configuration-steps)。

步骤 2:安装依赖项

安装所需的依赖项。

  • Debian/Ubuntu:
    bash 复制代码
    sudo apt install -y curl dialog freerdp3-x11 git iproute2 libnotify-bin netcat-openbsd

在 Debian 12(“bookworm”)上,您需要启用 backports 存储库才能使用 freerdp3-x11 软件包。
有关说明,请参阅 https://backports.debian.org/Instructions。

  • Fedora/RHEL:
    bash 复制代码
    sudo dnf install -y curl dialog freerdp git iproute libnotify nmap-ncat
  • Arch Linux:
    bash 复制代码
    sudo pacman -Syu --needed -y curl dialog freerdp git iproute2 libnotify openbsd-netcat
  • openSUSE:
    bash 复制代码
    sudo zypper install -y curl dialog freerdp git iproute2 libnotify-tools netcat-openbsd
  • Gentoo Linux:
    bash 复制代码
    sudo emerge --ask=n net-misc/curl dev-util/dialog net-misc/freerdp:3 dev-vcs/git sys-apps/iproute2 x11-libs/libnotify net-analyzer/openbsd-netcat

WinApps 需要 FreeRDP 版本 3 或更高版本。如果您的发行版无法通过软件包管理器获取,您可以安装 Flatpak

bash 复制代码
flatpak install flathub com.freerdp.FreeRDP
sudo flatpak override --filesystem=home com.freerdp.FreeRDP # 使用 `+home-drive`

但是,如果您在运行 Flatpak 时遇到类似 #233 的奇怪问题,请根据 本指南 从源代码编译 FreeRDP。

bash 复制代码
##################################
#   WINAPPS CONFIGURATION FILE   #
##################################

# INSTRUCTIONS
# - Leading and trailing whitespace are ignored.
# - Empty lines are ignored.
# - Lines starting with '#' are ignored.
# - All characters following a '#' are ignored.

# [WINDOWS USERNAME]
RDP_USER="MyWindowsUser"

# [WINDOWS PASSWORD]
# NOTES:
# - If using FreeRDP v3.9.0 or greater, you *have* to set a password
RDP_PASS="MyWindowsPassword"

# [WINDOWS DOMAIN]
# DEFAULT VALUE: '' (BLANK)
RDP_DOMAIN=""

# [WINDOWS IPV4 ADDRESS]
# NOTES:
# - If using 'libvirt', 'RDP_IP' will be determined by WinApps at runtime if left unspecified.
# DEFAULT VALUE:
# - 'docker': '127.0.0.1'
# - 'podman': '127.0.0.1'
# - 'libvirt': '' (BLANK)
RDP_IP="127.0.0.1"

# [VM NAME]
# NOTES:
# - Only applicable when using 'libvirt'
# - The libvirt VM name must match so that WinApps can determine VM IP, start the VM, etc.
# DEFAULT VALUE: 'RDPWindows'
VM_NAME="RDPWindows"

# [WINAPPS BACKEND]
# DEFAULT VALUE: 'docker'
# VALID VALUES:
# - 'docker'
# - 'podman'
# - 'libvirt'
# - 'manual'
WAFLAVOR="docker"

# [DISPLAY SCALING FACTOR]
# NOTES:
# - If an unsupported value is specified, a warning will be displayed.
# - If an unsupported value is specified, WinApps will use the closest supported value.
# DEFAULT VALUE: '100'
# VALID VALUES:
# - '100'
# - '140'
# - '180'
RDP_SCALE="100"

# [MOUNTING REMOVABLE PATHS FOR FILES]
# NOTES:
# - By default, `udisks` (which you most likely have installed) uses /run/media for mounting removable devices.
#   This improves compatibility with most desktop environments (DEs).
# ATTENTION: The Filesystem Hierarchy Standard (FHS) recommends /media instead. Verify your system's configuration.
# - To manually mount devices, you may optionally use /mnt.
# REFERENCE: https://wiki.archlinux.org/title/Udisks#Mount_to_/media
REMOVABLE_MEDIA="/run/media"

# [ADDITIONAL FREERDP FLAGS & ARGUMENTS]
# NOTES:
# - You can try adding /network:lan to these flags in order to increase performance, however, some users have faced issues with this.
# DEFAULT VALUE: '/cert:tofu /sound /microphone +home-drive'
# VALID VALUES: See https://github.com/awakecoding/FreeRDP-Manuals/blob/master/User/FreeRDP-User-Manual.markdown
RDP_FLAGS="/cert:tofu /sound /microphone +home-drive"

# [DEBUG WINAPPS]
# NOTES:
# - Creates and appends to ~/.local/share/winapps/winapps.log when running WinApps.
# DEFAULT VALUE: 'true'
# VALID VALUES:
# - 'true'
# - 'false'
DEBUG="true"

# [AUTOMATICALLY PAUSE WINDOWS]
# NOTES:
# - This is currently INCOMPATIBLE with 'manual'.
# DEFAULT VALUE: 'off'
# VALID VALUES:
# - 'on'
# - 'off'
AUTOPAUSE="off"

# [AUTOMATICALLY PAUSE WINDOWS TIMEOUT]
# NOTES:
# - This setting determines the duration of inactivity to tolerate before Windows is automatically paused.
# - This setting is ignored if 'AUTOPAUSE' is set to 'off'.
# - The value must be specified in seconds (to the nearest 10 seconds e.g., '30', '40', '50', etc.).
# - For RemoteApp RDP sessions, there is a mandatory 20-second delay, so the minimum value that can be specified here is '20'.
# - Source: https://techcommunity.microsoft.com/t5/security-compliance-and-identity/terminal-services-remoteapp-8482-session-termination-logic/ba-p/246566
# DEFAULT VALUE: '300'
# VALID VALUES: >=20
AUTOPAUSE_TIME="300"

# [FREERDP COMMAND]
# NOTES:
# - WinApps will attempt to automatically detect the correct command to use for your system.
# DEFAULT VALUE: '' (BLANK)
# VALID VALUES: The command required to run FreeRDPv3 on your system (e.g., 'xfreerdp', 'xfreerdp3', etc.).
FREERDP_COMMAND=""

# [TIMEOUTS]
# NOTES:
# - These settings control various timeout durations within the WinApps setup.
# - Increasing the timeouts is only necessary if the corresponding errors occur.
# - Ensure you have followed all the Troubleshooting Tips in the error message first.

# PORT CHECK
# - The maximum time (in seconds) to wait when checking if the RDP port on Windows is open.
# - Corresponding error: "NETWORK CONFIGURATION ERROR" (exit status 13).
# DEFAULT VALUE: '5'
PORT_TIMEOUT="5"

# RDP CONNECTION TEST
# - The maximum time (in seconds) to wait when testing the initial RDP connection to Windows.
# - Corresponding error: "REMOTE DESKTOP PROTOCOL FAILURE" (exit status 14).
# DEFAULT VALUE: '30'
RDP_TIMEOUT="30"

# APPLICATION SCAN
# - The maximum time (in seconds) to wait for the script that scans for installed applications on Windows to complete.
# - Corresponding error: "APPLICATION QUERY FAILURE" (exit status 15).
# DEFAULT VALUE: '60'
APP_SCAN_TIMEOUT="60"

# WINDOWS BOOT
# - The maximum time (in seconds) to wait for the Windows VM to boot if it is not running, before attempting to launch an application.
# DEFAULT VALUE: '120'
BOOT_TIMEOUT="120"

为保护您的 Windows 密码,请确保 ~/.config/winapps/winapps.conf 仅可由您的用户帐户访问。

bash 复制代码
chown $(whoami):$(whoami) ~/.config/winapps/winapps.conf
chmod 600 ~/.config/winapps/winapps.conf

RDP_USERRDP_PASS 必须与完整的 Windows 用户帐户和密码相对应,例如在 Windows 安装期间创建的帐户和密码或为域用户创建的帐户和密码。用户/PIN 组合不适用于 RDP 访问。

如果您希望使用其他 WinApps 后端(除 Docker 外),请取消注释并将 WAFLAVOR="docker" 更改为 WAFLAVOR="podman"WAFLAVOR="libvirt"

配置选项说明

  • 如果您在局域网中使用现有的 Windows RDP 服务器,则必须使用“RDP_IP”指定 Windows 服务器的位置。您也可以为此服务器配置静态 IP 地址。
  • 如果您使用“libvirt”运行启用了 NAT 的 Windows 虚拟机,请将“RDP_IP”注释掉,WinApps 将自动检测虚拟机的本地 IP 地址。
  • 对于域用户,您可以取消注释“RDP_DOMAIN”并进行更改。
  • 在高分辨率 (UHD) 显示器上,您可以将“RDP_SCALE”设置为您想要使用的比例(100、140 或 180)。
  • 要向 FreeRDP 调用添加其他标志(例如“/prevent-session-lock 120”),请取消注释并使用“RDP_FLAGS”配置选项。
  • 对于多显示器设置,您可以尝试将“/multimon”添加到“RDP_FLAGS”。但是,FreeRDP 的一个错误可能会导致黑屏,在这种情况下,您应该撤消此更改。
  • 要启用非英语输入和无缝语言切换,您可以尝试将“/kbd:unicode”添加到“RDP_FLAGS”。这可确保客户端输入以 Unicode 序列发送。
  • 如果启用“DEBUG”,则每次应用程序启动时都会在“~/.local/share/winapps/winapps.log”中创建日志。
  • 如果您使用的系统上的 FreeRDP 命令不是“xfreerdp”或“xfreerdp3”,则可以使用“FREERDP_COMMAND”指定正确的命令。

步骤 4:测试 FreeRDP

  1. 运行以下命令测试建立 RDP 会话,并将 /u:/p:/v: 的值替换为 ~/.config/winapps/winapps.conf 中指定的正确值。
bash 复制代码
xfreerdp3 /u:"您的 Windows 用户名" /p:"您的 Windows 密码" /v:192.168.122.2 /cert:tofu

# 或者,如果您使用 Flatpak 安装 FreeRDP,请运行:
flatpak run --command=xfreerdp com.freerdp.FreeRDP /u:"您的 Windows 用户名" /p:"您的 Windows 密码" /v:192.168.122.2 /cert:tofu
  • 请注意,正确的 FreeRDP 命令可能因您的系统而异(例如 xfreerdpxfreerdp3 等)。
  • 确保在上述命令中使用了 Windows 实例的正确 IP 地址。
  • 如果终端窗口中出现提示,请选择永久接受证书。

如果 Windows 桌面出现在“FreeRDP”窗口中,则表示配置成功,并且正确的 RDP TLS 证书已在 Linux 主机上注册。断开 RDP 会话并跳过以下调试步骤。

  1. [调试步骤] 如果检测到过期或过期的证书,“FreeRDP”命令将显示类似以下内容的输出。在这种情况下,需要删除旧证书并安装新的 RDP TLS 证书。
复制代码
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @           WARNING: CERTIFICATE NAME MISMATCH!           @
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

   The hostname used for this connection (192.168.122.2:3389)
   does not match the name given in the certificate:
   Common Name (CN):
           RDPWindows
   A valid certificate for the wrong name should NOT be trusted!

   The host key for 192.168.122.2:3389 has changed

   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

   IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
   Someone could be eavesdropping on you right now (man-in-the-middle attack)!
   It is also possible that a host key has just been changed.
   The fingerprint for the host key sent by the remote host is 8e:b4:d2:8e:4e:14:e7:4e:82:9b:07:5b:e1:68:40:18:bc:db:5f:bc:29:0d:91:83:f9:17:f9:13:e6:51:dc:36
   Please contact your system administrator.
   Add correct host key in /home/rohanbarar/.config/freerdp/server/192.168.122.2_3389.pem to get rid of this message.

如果您遇到上述错误,请删除所有与 Windows 关联的旧的或过期的 RDP TLS 证书,因为它们可能会阻止“FreeRDP”建立连接。

这些证书位于“~/.config/freerdp/server/”中,并遵循“_.pem”的命名格式(例如,“192.168.122.2_3389.pem”、“127.0.0.1_3389.pem”等)。

如果您将 FreeRDP 用于 WinApps 以外的用途,请确保仅删除与相关 Windows 虚拟机相关的证书。如果未找到相关证书,则无需执行任何操作。

删除后,重新尝试建立 RDP 会话。

步骤 5:运行 WinApps 安装程序

在 Windows 保持开启状态的情况下,运行 WinApps 安装程序。

bash 复制代码
bash <(curl https://raw.githubusercontent.com/winapps-org/winapps/main/setup.sh)

WinApps 安装完成后,运行“winapps-setup --help”即可查看其他参数列表。

添加其他预定义应用程序

将您自己的应用程序(包含自定义图标和 MIME 类型)添加到安装程序非常简单。只需复制 WinApps 仓库中“apps”文件夹中的其中一个应用程序配置,然后:

  1. 修改名称和变量,使其反映应用程序的适当/所需值。
  2. 将“icon.svg”替换为您的应用程序的 SVG 文件(确保图标已获得相应的许可)。
  3. 删除并重新安装 WinApps。
  4. 测试并验证您的配置后,提交拉取请求,将您的应用程序作为官方支持的应用程序添加到 WinApps(可选,但建议这样做)。

手动运行应用程序

WinApps 提供了手动模式,用于运行 WinApps 安装程序未配置的应用程序。此功能通过“manual”标志完成。Windows PATH 中的可执行文件不需要完整路径定义。

bash 复制代码
winapps manual "C:\my\directory\executableNotInPath.exe"
winapps manual executableInPath.exe

更新 WinApps

安装程序可以多次运行。要更新您的 WinApps 安装:

  1. 运行 WinApps 安装程序以从系统中移除 WinApps。
  2. 从 WinApps GitHub 仓库中拉取最新更改。
  3. 使用 WinApps 安装程序,通过运行“winapps-setup”重新安装 WinApps。

WinApps 启动器(可选)

WinApps 启动器 提供了一个简单的系统托盘菜单,可轻松启动已安装的 Windows 应用程序、打开完整的桌面 RDP 会话以及控制 Windows 虚拟机或容器。您可以启动、停止、暂停、重启或休眠 Windows,以及从便捷的列表中访问已安装的应用程序。这款轻量级的可选工具有助于简化您的整体 WinApps 体验。

关于项目

在 Linux(Ubuntu/Fedora)和 GNOME/KDE 中运行 Windows 应用程序(例如 Microsoft Office/Adobe),就好像它们是本机操作系统的一部分一样,包括 Nautilus 集成,就像它们是操作系统原生的一样。
MIT
Shell
10,945
336
48
2023-07-05
2025-10-08

增长趋势 - stars