Batch file.
Code:
cd /User/Docs/
for i in */; do
tar -czvf $i.tar.gz $i
done
There is the logical flow in unix bash, 'fraid you're on you own in converting to MS batch files.
Also investigate the WinRar cli syntax, if it has a cli backend that is -- but why oh why do you want to use RAR compression?

It is proprietary and not very interoperable.