Home arrow Blog arrow Making PuTTY (really) Portable
Sunday, 01 August 2010

Login Form

Search

Subscribe

Subscribe to KeithsCode.com
 

Get Stuff

CafePress Store
 
Making PuTTY (really) Portable

PuTTY is one of those indispensable little programs that I take with me everywhere I go. I used to just run it off my USB flash drive, and type in the host name on each different computer that I ran it on. This got very tedious, very quickly. I wanted to be able to take my host definitions (which are stored in the registry) with me, too, and I didn't want to leave a bunch of junk on every computer I used. After a bit of looking, I found information in the PuTTY documentation about putting the configuration settings into a file. This seemed lacking to me since I never knew what drive letter would be assigned to my thumb drive and I didn't want to edit the batch file every time. So, I fixed it ...

First, I had to fix the puttyrnd.reg file to point to my thumb drive for the location of the random seed file. I probably could have left out this part and let PuTTY put it in the Application Data folder, but I didn't want to leave anything on the computer I was using and I wasn't sure I'd always have write permissions to that directory. I thought, at first, that I could just use the %CD% environment variable in the batch file, but then realized that I needed to escape the path with extra backslashes since it was going into a quoted string. So I came up with:

set MyPath=%CD:\=\\%\\putty.rnd

Now, when I run the batch file, it sets the path for the .rnd file to whatever drive\directory the batch file is in.

The only other change I had to make to get it working was a modification of the puttyrnd.reg file. I simply stripped the last line out of the file and renamed it puttyrnd.tmp. I then create the puttyrnd.reg file within my batch file.

Here is a listing of all of the used files:

Listing of putty.bat
@echo off :: Set MyPath with proper escaping for entry into the registry set MyPath=%CD:\=\\%\\putty.rnd   :: Add the site definitions into the registry regedit /s putty.reg   :: Build the puttyrnd.reg file so that it uses the current dir and add it to the registry type puttyrnd.tmp > puttyrnd.reg echo "RandSeedFile"="%MyPath%" >> puttyrnd.reg regedit /s puttyrnd.reg   :: Run Putty (and wait for it to end) start /w putty.exe   :: Export the new site definitions in case something changed regedit /ea new.reg HKEY_CURRENT_USER\Software\SimonTatham\PuTTY   :: Put the new definitions into the putty.reg file copy new.reg putty.reg del new.reg   :: Delete everything out of the registry regedit /s puttydel.reg
 

Listing of puttyrnd.tmp
REGEDIT4 [HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]
 

Listing of puttydel.reg
REGEDIT4 [-HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]  
 

If you would like to download a zip file with all of these files plus PuTTY you can get it by going to Portable PuTTY in the online documents.

Of course, you need to generate the putty.reg file that contains all your site definitions before you run the batch file. You can build the file by typing the following at the command line:

regedit /ea putty.reg HKEY_CURRENT_USER\Software\SimonTatham\PuTTY

Hopefully this helps someone as much as it has me ...

Keith

 

Comments
Search
You must be logged in to leave a comment.
No Account?
Join Now!
(It's Free.)

3.25 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."