Cook ran his career mark to 13-4 against the Padres, his most wins against any opponent. Cook, who won his sixth straight decision, improved to 6-1 with a 1.60 ERA in his last nine starts in San Diego. Cook has a career ERA of 2.66 against the Padres in 23 appearances, including 21 starts.
Although Cook was not as sharp as he has been in the past against San Diego, the right-hander made pitches in the right spots to escaped numerous jams, including two with the bases loaded.
"It was really weird today," Cook said. "I pitched with a lot of guys on base, I gave up a lot of hits. The defense came up big behind me and I was able to get some strikeouts when I need to."
Cook pitched six innings and tied his career high with eight strikeouts. In bases-loaded situations in the first and third innings, he allowed one run.
"He did a great job of wiggling out of a couple of messes early in the game," Colorado manager Jim Tracy said.
Cook allowed a first-inning run, then pitched out of trouble in every inning except the second when he had his only 1-2-3 inning. He allowed eight hits and walked four.
The Rockies were leading 4-1 in the sixth when Barmes hit a three-run homer, his 11th, off Mike Ekstrom.
"It's always nice to get a swing on the ball and hit it like that," Barmes said. "Especially coming off the break, and my first three at-bats were not exactly the way I was planning on them going. I got a little jumpy. It was nice to slow it down and get a good pitch to hit."
Smith added a two-run homer off Ryan Webb in the eighth as Colorado scored at least seven runs for the fourth time in six games.
Todd Helton added four hits for the Rockies, including two doubles that left him two short of becoming the 50th player in baseball history with 500.
Colorado (48-41) improved to 30-13 since Tracy replaced Clint Hurdle as manager. San Diego has lost 22 of 30.
"We wanted to come out and pick it right back up and not slow down," Barmes said.
In the third, the Padres loaded the bases with two outs before Cook struck out Alfonso, who stranded eight baserunners, including five in scoring position. San Diego left 14 men on base.
"If there is any time to really get him, it seems to be early because he kind of shifts to a different level," said San Diego's Chase Headley, who had three hits. "Once he got about the fourth or fifth inning, he got a lot better."
Chad Gaudin (4-8) walked Cook with the bases loaded in second.
Gaudin allowed four runs -- one earned -- and four hits over five innings. He walked four and struck out eight but was the victim of two errors, including one by Gold Glove first baseman Adrian Gonzalez.
Gonzalez, one of two San Diego All-Stars, drew two walks, giving him 43 in San Diego's last 43 games.
Rockies All-Star RF Brad Hawpe was held out of the starting lineup, which had been decided upon before the All-Star break by Tracy. "Knowing the whirlwind he obviously went through over the last couple of days, I wanted him to have another day off to get rest," Tracy said. ... Colorado RHP Jason Marquis will remain Sunday's starter against the Padres despite not having pitched in the All-Star game. Tracy said another reason not to move Marquis up to Saturday is that he has a little irritation on his right index finger. ... Padres rookie Kyle Banks doubled in the sixth in his first pinch-hit appearance.