求助:在Ubuntu+RetroPie环境下创建.sh脚本通过Wine运行Windows版Steam游戏
Hey there! I’ve helped a bunch of folks get Windows Steam games running via shell scripts in RetroPie, so let’s walk through this step by step to fix those formatting issues you’re hitting.
Core Idea
Instead of manually opening Windows Steam and clicking play, we’ll use Wine’s command line to launch Steam directly into your target game—this is the key to making a reliable shell script.
1. Locate Your Windows Steam Installation Path
First, confirm where Steam is installed in your Wine container. The default path is usually:
~/.wine/drive_c/Program Files (x86)/Steam/Steam.exe
If you’re using a custom Wine prefix (e.g., a separate container for games), replace ~/.wine with your prefix’s path (like ~/Games/MyWinePrefix).
2. Grab the Game’s Steam AppID
Every Steam game has a unique AppID—you’ll need this to launch it directly:
- Open Windows Steam, right-click your game → Properties
- Look at the URL in the "General" tab— the number at the end is your AppID (e.g., Half-Life 2 uses
220) - Alternatively, find the number in the game’s Steam Store page URL.
3. Write the Shell Script (Fixing Formatting Issues)
Create a new .sh file (e.g., my_windows_game.sh) and paste this template, replacing placeholders with your details:
#!/bin/bash # Optional: Set custom Wine prefix (remove if using default ~/.wine) export WINEPREFIX="$HOME/Games/MyWinePrefix" # Launch Windows Steam directly into your game wine "$HOME/.wine/drive_c/Program Files (x86)/Steam/Steam.exe" -applaunch YOUR_GAME_APPID # Optional: Return to EmulationStation after game exits emulationstation &
Critical Formatting Notes (Common Pitfalls!)
- Always start with
#!/bin/bash: This tells your system which interpreter to use—missing this is the #1 cause of script failures. - Quote paths with spaces: Directories like
Program Fileshave spaces, so wrap the entire Steam.exe path in double quotes ("...") to avoid errors. - Double-check WINEPREFIX: If you’re using a non-default prefix, make sure this line points to the correct folder.
4. Set Script Permissions
Your script won’t run unless it has execute permissions. Run this command in terminal:
chmod +x /path/to/your/my_windows_game.sh
5. Add to RetroPie’s Game List
To see the game in EmulationStation:
- Move your
.shscript to RetroPie’s PC roms directory (create it if missing):~/RetroPie/roms/pc/ - You can either:
- Use RetroPie’s built-in Scraper (via the RetroPie menu) to auto-add the game to your list, or
- Manually edit
~/RetroPie/roms/pc/gamelist.xmlto add an entry like this:<game> <path>./my_windows_game.sh</path> <name>Your Game Name</name> <desc>Short description of your game</desc> <image>./boxart/your_game_boxart.png</image> </game>
内容的提问来源于stack exchange,提问作者Josh Garvey

