Skip to content

Commit

Permalink
Merge pull request pyenv-win#463 from pyenv-win/feature/shims.lnk_for…
Browse files Browse the repository at this point in the history
…_exe_files

Shortcut link for exe files i.e. file.lnk
  • Loading branch information
kirankotari authored Feb 15, 2023
2 parents fb765a1 + 8917232 commit 0ccca5c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pyenv-win/bin/pyenv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ if exist "%exe%.bat" (
) else if exist "%exe%.vbs" (
set "exe=cscript //nologo "%exe%.vbs""

) else if exist "%exe%.lnk" (
set "exe=start '' "%exe%.bat""
) else (
echo pyenv: no such command '%1'
exit /b 1
Expand Down
33 changes: 29 additions & 4 deletions pyenv-win/libexec/libs/pyenv-lib.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ Function GetExtensionsNoPeriod(addPy)
Next
End Function

' pyenv - bin - exe files
Sub LinkExeFiles(baseName, file)
' WScript.echo "kkotari: pyenv-lib.vbs link exe files..!"
Dim filespec
Dim link
link = strDirShims &"\"& baseName &".lnk"
If Not objfs.FileExists(link) Then
Set filespec = objws.CreateShortcut(link)
filespec.TargetPath = file
filespec.Description = baseName
filespec.IconLocation = file &", 2"
filespec.WindowStyle = "1"
filespec.WorkingDirectory = objfs.getParentFolderName(file)
filespec.Save
End If
End Sub

' pyenv - bin - windows
Sub WriteWinScript(baseName)
' WScript.echo "kkotari: pyenv-lib.vbs write win script..!"
Expand Down Expand Up @@ -369,8 +386,12 @@ Sub Rehash()
' WScript.echo "kkotari: pyenv-lib.vbs rehash for winBinDir"
If exts.Exists(LCase(objfs.GetExtensionName(file))) Then
baseName = objfs.GetBaseName(file)
WriteWinScript baseName
WriteLinuxScript baseName
If LCase(objfs.GetExtensionName(file)) <> "exe" Then
LinkExeFiles baseName, file
Else
WriteWinScript baseName
WriteLinuxScript baseName
End If
End If
Next

Expand All @@ -379,8 +400,12 @@ Sub Rehash()
' WScript.echo "kkotari: pyenv-lib.vbs rehash for winBinDir\Scripts"
If exts.Exists(LCase(objfs.GetExtensionName(file))) Then
baseName = objfs.GetBaseName(file)
WriteWinScript baseName
WriteLinuxScript baseName
If LCase(objfs.GetExtensionName(file)) <> "exe" Then
LinkExeFiles baseName, file
Else
WriteWinScript baseName
WriteLinuxScript baseName
End If
End If
Next
End If
Expand Down

0 comments on commit 0ccca5c

Please sign in to comment.