First, you write the director-vectors of each straight line:
Then you consider a straight line N that is perpendicular over both straight lines, then N=v(d1) x v(d2) (vectorial product)
You find the ecuations for the plan determined by the first straight line and N:
(to do that you consider a point A located over the straight line, be A(1,1,-1) )
=> | x-1 y-1 z+1 |
| 4 2 1 | =0 => 3x-9y+6z+4=0
| -1 1 2 |
The same for the plan determined by the second straight line and N:
These 2 last ecuations represent the ecuation of N.
Then you intersect N with every straight line to find the intersection points C and D, and finally you find the distance of them by calculating CD.
I hope I didn't make any mistake in calculus. Anyhow, first of all you have to prove that the two straight lines are not in the same plan, otherwise the distance between them is 0.