Skip to content

Instantly share code, notes, and snippets.

@7wells
Last active March 15, 2024 18:10
Show Gist options
  • Save 7wells/4f8bd463cfe89879faaed2c2c98027f8 to your computer and use it in GitHub Desktop.
Save 7wells/4f8bd463cfe89879faaed2c2c98027f8 to your computer and use it in GitHub Desktop.
How to create a shortcut in Windows startup folder for Pageant incl. encrypted keys
#### How to create a shortcut in Windows startup folder for Pageant incl. encrypted keys
## References
# https://stackoverflow.com/questions/31814060/create-a-shortcut-with-parameters-added-to-the-program-path
# The below batch file creates a temporary vbs script, executes it to create the startup entry
# for pageant, and it cleanly deletes the temporary vbs file afterwards. As shown in the example,
# you can add multiple keys in `Arguments`. Replace them by your key file name(s). You might also need
# to adjust the `TargetPath` to your pageant.exe file.
```
@echo off
cls
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Pageant.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PROGRAMFILES%\PuTTY\pageant.exe" >> %SCRIPT%
echo oLink.Arguments = "--encrypted %USERPROFILE%\.ssh\id_rsa.ppk %USERPROFILE%\.ssh\id_nistp256.ppk" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment