Posts tagged ‘relative path’

26/02/2011

Relative batchfile paths

In a previous post “Batch file to perform SSH commands and transfer files from Windows to Linux” I used a batchfile to call on plink.exe as follows:

C:\Path\plink.exe

This is all well and good, but if this path changes for whatever reason (i.e. you save it to another directory or machine) then it won’t work.

There is an easy fix that gives the relative path, as long as the .bat and .exe are in the same directory:

%~dp0plink.exe

Hope this proves useful.