There are a few ways you can do this.
I would suggest the easiest way is is to buy an ethernet switch.
Connect all your computers and the printer to the switch, give them an ip address all in the same range.
this way the printer would always be connected to the network therefore you could always use the ip address for the printer to send command to.
i.e. dir/w >printerip.