What you seem to need here is to compute a Moore-Penrose pseudoinverse (essentially the same as Michael's answer, but recast in different form).
Start with
$\mathbf A=\mathbf B^{-1}\mathbf C$
Now $\mathbf C$ always has a singular value decomposition (SVD): $\mathbf C=\mathbf U\mathbf \Sigma\mathbf V^\top$, where $\mathbf U$ and $\mathbf V$ are orthogonal, and $\mathbf \Sigma$ is diagonal. The Moore-Penrose inverse can be computed as
$\mathbf C^+=\mathbf V\mathbf \Sigma^+\mathbf U^\top$
where $\mathbf \Sigma^+$ is obtained by reciprocating only the nonzero diagonal entries (or, in inexact arithmetic, reciprocate the entries that are larger than $\varepsilon\sigma_1$, where $\sigma_1$ is the largest diagonal entry, and $\varepsilon$ is machine epsilon.) This coincides with the usual inverse if $\mathbf C$ is in fact invertible.
Having the SVD on hand, we can do the following:
$\begin{align*} \mathbf A&=\mathbf B^{-1}\mathbf C\\ \mathbf A&=\mathbf B^{-1}(\mathbf U\mathbf \Sigma\mathbf V^\top)\\ \mathbf A\mathbf V&=\mathbf B^{-1}\mathbf U\mathbf \Sigma\\ \mathbf A\mathbf V\mathbf \Sigma^+&=\mathbf B^{-1}\mathbf U\\ \mathbf A\mathbf V\mathbf \Sigma^+\mathbf U^\top&=\mathbf B^{-1}\\ \mathbf B&=(\mathbf A\mathbf V\mathbf \Sigma^+\mathbf U^\top)^{-1} \end{align*}$