Similar to what JJ said, but I would Control+Alt+T to transform a copy of the path in a Shape layer. With the reference point set to top left, put the left and top border sizes in the X and Y fields. In the Width and Height fields, you can take advantage that Photoshop now allows simple math in numeric fields, so you would add the total borders left and right, or top and bottom, to the existing values. After the transform, in the Shape tool, set the path operations to Exclude Overlapping. Scripting would be good for this, since you could give better UI controls than, the Transform Options bar, which I find painfully fiddly to use. You could also edit the border sizes later by independantly adjusting the size of the two rectangles.
... View more