Mario Palumbo Asked: 2021-04-09 02:36:01 +0800 CST2021-04-09 02:36:01 +0800 CST 2021-04-09 02:36:01 +0800 CST Ubuntu 20.04 - WineHQ 6.0 - 为程序创建 .lnk 快捷方式 772 此链接:https ://unix.stackexchange.com/questions/509360 它解释了如何将程序添加到 Wine 菜单: wine winemenubuilder /path/to/link.lnk 但是我的特定程序没有 .lnk 文件。 如何创建 .lnk 文件? 20.04 1 个回答 Voted Best Answer Mario Palumbo 2021-04-13T04:09:38+08:002021-04-13T04:09:38+08:00 我发明了保证与葡萄酒完美兼容的正确解决方案: lnk () { cat <<EOF > /tmp/shortcut.vbs Set FSO = CreateObject("Scripting.FileSystemObject") TargetPath = FSO.GetAbsolutePathName(WScript.Arguments(0)) WorkingDirectory = FSO.GetParentFolderName(TargetPath) Set lnk = CreateObject("WScript.Shell").CreateShortcut(WScript.Arguments(1)) lnk.TargetPath = TargetPath lnk.WorkingDirectory = WorkingDirectory lnk.Save EOF wine wscript '//B' 'Z:\tmp\shortcut.vbs' "$@" 2> /dev/null local exit_code=$? sync; rm -f /tmp/shortcut.vbs; sync return $exit_code } 我能够干净地调用该函数: lnk 'C:\Program Files (x86)\Rufus\rufus.exe' 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Rufus.lnk' 在我的例子中,这是一个程序的安装功能: update_rufus () { local old_version="$(cat ~/'.wine/dosdevices/c:/Program Files (x86)/Rufus/version.txt' 2> /dev/null)" local link="$(wget -q 'https://api.github.com/repos/pbatard/rufus/releases/latest' -O - | grep '"browser_download_url":' | grep -o -m 1 -E '[^"]+/rufus-[0-9.]+\.exe')" wget -q "$link" -O rufus.exe local exit_code=$? if [[ $exit_code -eq 0 ]]; then mkdir -p ~/'.wine/drive_c/Program Files (x86)/Rufus' echo "$link" | perl -lpe 's|^.*/rufus-([0-9.]+)\.exe$|\1|' > ~/'.wine/drive_c/Program Files (x86)/Rufus/version.txt' mv rufus.exe ~/'.wine/drive_c/Program Files (x86)/Rufus' lnk 'C:\Program Files (x86)\Rufus\rufus.exe' 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Rufus.lnk' local new_version="$(cat ~/'.wine/dosdevices/c:/Program Files (x86)/Rufus/version.txt')" if [[ "$new_version" == "$old_version" ]]; then echo "Rufus is already the newest version ($new_version)." else echo "Rufus has been successfully updated ($new_version)." fi else echo 'An error has occurred.' fi return $exit_code }
我发明了保证与葡萄酒完美兼容的正确解决方案:
我能够干净地调用该函数:
在我的例子中,这是一个程序的安装功能: