Vilnius has better train connection with both Poland and Russia than Riga.
Some more details about the trip:
The direct train from Warszawa (7:25) to Vilnius (17:53) is in fact a two trains with change at border station Šeštokai, because of different gauge in Poland and Lithuania. The change is guaranteed, the Lithuanian train waits for the Polish one. At Polish territory you use IR, an ordinary international ticket from Šeštokai to Vilnius costs € 13,50, available at all international counters at European stations.
There are two direct trains from Vilnius to St. Petersburg, Peter you can add it to your timetables
Vilnius 15:48 – St. Petersburg 11:00
in summer runs daily, otherwise in odd days
platskartniy class: 1974 RUB (~ € 50)
kupeyniy class: 3832 RUB (~ € 97)
Vilnius 18:18 – St. Petersburg 9:00
platskartniy class: 2241 RUB (~ € 57)
kupeyniy class: 3522 RUB (~€ 89)
Platskartnyi class consist of 6-berth compartments open to aisle, kupeyniy class consist of closed 4-berth comparments. The tickets are available probably only at Vilnius station, but you should try to buy an e-ticket at http://poezda.net (you have to switch to Russian language version)