![Windows 바로 가기 파일(.LNK)을 실행하는 Cygwin](https://rvso.com/image/1417416/Windows%20%EB%B0%94%EB%A1%9C%20%EA%B0%80%EA%B8%B0%20%ED%8C%8C%EC%9D%BC(.LNK)%EC%9D%84%20%EC%8B%A4%ED%96%89%ED%95%98%EB%8A%94%20Cygwin.png)
Windows에서 cmd 대체품으로 Cygwin을 사용하고 있으며 시스템 PATH 변수를 정리하는 중입니다.
이제 명령줄에서 사용하는 모든 작은 앱과 소프트웨어가 포함된 PATH에 exe 및 바로 가기(.LNK) 파일이 포함된 폴더가 있습니다.
모든 것이 CMD를 통해 작동하지만 바로 가기인 .LNK 파일은 Cygwin을 통해 작동하지 않습니다. 대신 나는 얻는다
bash: /cygdrive/e/Apps/uniserver.lnk: 바이너리 파일을 실행할 수 없습니다.
내 유일한 추측은 .lnk가 심볼릭 링크라고 생각하기 때문입니까?
어쨌든 Cygwin이 바로가기를 실행하도록 할 수 있습니까?
답변1
cygstart
다음의 일부인 유틸리티를 사용하여 Cygwin에서 Windows LNK 파일을 실행할 수 있습니다.시구틸스 패키지, 다음과 같습니다:
cygstart [OPTION]... FILE [ARGUMENTS]
보다cygstart --help
사용 가능한 옵션에 대해
귀하의 경우에는 다음으로 충분합니다.
cygstart /cygdrive/e/Apps/uniserver.lnk
답변2
나는 비슷한 설정을 수행했으며 .lnk
매번 입력하는 시간을 절약할 수 있는지 생각했습니다. 시험을 마친 command_not_found_handle
훅Bash 4.0부터 추가되었으며 작동하는 것처럼 보입니다.
# add this to your .bashrc
command_not_found_handle ()
{
if [[ $1 == *.* || $1 == */* ]]; then
echo "$1: command not found"
return 127
fi
local binbase=/cygdrive/e/Apps/
local name=$1
shift
# You might want to tweak precedence
if [[ -f ./$name.bat ]]; then
exec "./$name.bat" "$@"
elif [[ -f ./$name.lnk ]]; then
cygstart "./$name.lnk" "$@"
elif [[ -f $binbase/$name.bat ]]; then
exec "$binbase/$name.bat" "$@"
elif [[ -f $binbase/$name.lnk ]]; then
cygstart "$binbase/$name.lnk" "$@"
else
echo "$name: command not found"
return 127
fi
}
예를 들어 입력하면 uniserver
이 후크가 실행되고 /cygdrive/e/Apps/uniserver.lnk
실행되는 것을 찾습니다.
편집하다:전체 $PATH에서 바로가기를 찾는 대안입니다.
command_not_found_handle ()
{
if [[ $1 == *.* || $1 == */* ]]
then
echo "$1: command not found"
return 127
fi
local name=$1
shift
if [[ -f ./$name.bat ]]
then
exec "./$name.bat" "$@"
elif [[ -f ./$name.lnk ]]
then
start "./$name.lnk" "$@"
elif [[ -f $(type -P $name.bat) ]]
then
exec "$(type -P $name.bat)" "$@"
elif [[ -f $(type -P $name.lnk) ]]
then
cygstart "$(type -P $name.lnk)" "$@"
else
echo "$name: command not found"
return 127
fi
}
답변3
DOS 내장 명령을 사용하십시오 start
. 하지만 Cygwin에는 DOS 내장 기능에 대한 액세스 권한이 없는 것 같습니다. 따라서 mystart.bat와 같은 래퍼를 작성하고 래퍼 스크립트를 사용하여 LNK의 my를 시작해야 합니다.
Cygwin에서 LNK 파일을 "연결"하여 Cygwin이 래퍼를 자동으로 시작하도록 할 수는 없지만 다른 사람이 그렇게 하는 방법을 제안할 수는 있을 것입니다.