Via a Dirichlet form extension theorem and making full use of two-sided heat kernel estimates, we establish quenched invariance principles for ran- dom walks in random environments with a boundary. In particular, we prove that the random walk on a supercritical percolation cluster or among random conductances bounded uniformly from below in a half-space, quarter-space, etc., converges when rescaled diffusively to a reflecting Brownian motion, which has been one of the important open problems in this area. We establish a similar result for the random conductance model in a box, which allows us to improve existing asymptotic estimates for the relevant mixing time. Furthermore, in the uniformly elliptic case, we present quenched invariance prin- ciples for domains with more general boundaries.