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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: