After the League Two side's bright start, two quick goals from Diafra Sakho and Andre Ayew gave the Premier League side control before half-time.
Sakho slotted in his first goal since November from Sam Byram's pass, before Ayew tucked into the same bottom corner moments later.
The hosts went close via Harry Pell's volley and Jordon Forster's header.
James Collins and Byram both could have added further goals for the visitors, who made seven changes following top-flight losses at Manchester United and Southampton.
The best moment for Cheltenham, who were unchanged from Saturday's 3-0 league defeat by Carlisle, came with Pell's low volley across goal, but onrushing substitute Dan Holman could not quite get the required touch as he slid in at the far post.
The two sides' only previous meeting came at the same stage of this competition four years ago, resulting in a narrow 2-1 win for Hammers at their old home Upton Park.
The fourth-tier side performed respectfully again on Wednesday, but did not sufficiently test Hammers goalkeeper Adrian.
Slaven Bilic's side could have won by a greater margin, but Robins captain Kyle Storer cleared Angelo Ogbonna's fierce header off the line in the first half and, moments later, keeper Jonathan Flatt did well to stop Sakho turning in Ayew's low cross.
Cheltenham's exit ended League Two's representation in the EFL Cup before Thursday's third-round draw.
Match ends, Cheltenham Town 0, West Ham United 2.
Second Half ends, Cheltenham Town 0, West Ham United 2.
Foul by Sam Byram (West Ham United).
Kevin Dawson (Cheltenham Town) wins a free kick in the defensive half.
Foul by Cheikhou Kouyaté (West Ham United).
Harry Pell (Cheltenham Town) wins a free kick on the right wing.
Substitution, West Ham United. Domingos Quina replaces Edimilson Fernandes.
Attempt missed. Jordon Forster (Cheltenham Town) header from the centre of the box is just a bit too high. Assisted by Kyle Storer with a cross following a corner.
Corner,  Cheltenham Town. Conceded by Sam Byram.
Attempt missed. Pedro Obiang (West Ham United) header from the centre of the box is high and wide to the left. Assisted by Chicharito with a cross following a corner.
Corner,  West Ham United. Conceded by Jordon Forster.
Angelo Ogbonna (West Ham United) wins a free kick on the left wing.
Foul by Nigel Atangana (Cheltenham Town).
Chicharito (West Ham United) wins a free kick in the defensive half.
Foul by Carl Winchester (Cheltenham Town).
Delay over. They are ready to continue.
Delay in match Pedro Obiang (West Ham United) because of an injury.
Pedro Obiang (West Ham United) wins a free kick in the defensive half.
Foul by Kyle Storer (Cheltenham Town).
Offside, Cheltenham Town. Jamie Grimes tries a through ball, but Brian Graham is caught offside.
Attempt missed. Harry Pell (Cheltenham Town) right footed shot from a difficult angle on the right misses to the left. Assisted by Kevin Dawson with a cross.
Substitution, West Ham United. Cheikhou Kouyaté replaces Mark Noble.
Foul by Sam Byram (West Ham United).
Dan Holman (Cheltenham Town) wins a free kick in the attacking half.
Substitution, Cheltenham Town. Dan Holman replaces Mohamed Eisa.
Corner,  West Ham United. Conceded by Jordan Cranston.
Corner,  West Ham United. Conceded by Jordon Forster.
James Collins (West Ham United) wins a free kick in the defensive half.
Foul by Brian Graham (Cheltenham Town).
Substitution, Cheltenham Town. Brian Graham replaces Daniel Wright.
Substitution, West Ham United. Chicharito replaces Diafra Sakho.
.
Attempt missed. Diafra Sakho (West Ham United) header from the centre of the box is high and wide to the right. Assisted by Pedro Obiang with a cross.
Attempt saved. Mohamed Eisa (Cheltenham Town) right footed shot from the left side of the box is saved in the bottom left corner. Assisted by Kevin Dawson.
Attempt blocked. Mohamed Eisa (Cheltenham Town) right footed shot from the centre of the box is blocked. Assisted by Kevin Dawson.
Attempt missed. James Collins (West Ham United) header from the centre of the box is just a bit too high. Assisted by Mark Noble with a cross.
Corner,  West Ham United. Conceded by Jordan Cranston.
Attempt blocked. Diafra Sakho (West Ham United) right footed shot from outside the box is blocked. Assisted by Arthur Masuaku.
Sam Byram (West Ham United) wins a free kick in the defensive half.
Foul by Kevin Dawson (Cheltenham Town).
West Ham earned their first win of the season as they saw off Cheltenham Town in the EFL Cup second round.