Question

I've added this entry into the context menue of an USB stick via autorun.inf:

[AutoRun]
shell\pageant=Activate SSH Key
shell\pageant\command=PuTTY\pageant.exe PuTTY\davids.ppk

Both PuTTY\pageant.exe and PuTTY\davids.ppk are files on the USB stick and should be picked up from there.

When I run this in a shell from the root of the stick it works as intended. But starting it from the menu it tries to load the key from C:\Windows\system32\PuTTY\davids.ppk (checked with Process Monitor).

Trying to use a simple cmd script resulted in this output:

    C:\Windows\system32>cd PuTTY
    Das System kann den angegebenen Pfad nicht finden.

    C:\Windows\system32>pageant.exe davids.ppk
    Der Befehl "pageant.exe" ist entweder falsch geschrieben oder
    konnte nicht gefunden werden.

Is there a way to get this working properly? I guess it should be able to pass the drive letter or get the explorer to use the stick as working directory, but I don't know how. Since I want to use the stick on the go, I'd rather avoid hardcoding my local drive letter.

Was it helpful?

Solution

I think the easiest solution would be to create a batch file to do this for you. Something named activatekey.cmd like this:

REM switch to the directory containing this script
for %%a in (%0) do cd /D %%~da%%~pa

cd PuTTY
pageant.exe davids.ppk

Place the file activatekey.cmd in your USB stick, and change the autorun.inf to be:

[AutoRun]
shell\pageant=Activate SSH Key
shell\pageant\command=activatekey.cmd

OTHER TIPS

It seems it reads "Path" system variable. :( You may add the drive to path but getting the Drive letter is the problem. :-(

Update 1 : You can get the drive letter using a VB script.

Update 2 : Yes, I think you can do that. Check this page.

Update 3 : I tested the script. It works great.

Dim  oDrive
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
For Each oDrive In oFSO.Drives
WScript.Echo "Drive Letter" , oDrive.DriveLetter
WScript.Echo "Drive Type" , oDrive.DriveType
Next

Use some file existance check method to differenciate multiple USB drives.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top