Three men have been arrested over the shooting, at Sunbury about 3.15am on Tuesday.
Officers were in the car when it was peppered with bullets, forcing them to drive to the nearby fast-food outlet for cover.
They were soon met by a supervisor and as the four were checking on the safety of each other and McDonald’s staff, more shots were fired at their cars and one was rammed by a silver sedan before it sped from the scene.
Police, including the dog squad and air wing, swarmed the area in search of the attackers.
“This is outrageous behaviour,” Assistant Commissioner Luke Cornelius told reporters on Tuesday.
“Our police are here to keep the community safe and our police, when they come to work, come to work expecting to make a difference.”
Mr Cornelius said the officers and McDonald’s staff were being supported but none were physically injured.
A 33-year-old man of no fixed address and two men from Sunbury aged 26 and 18 are in custody.
The three were found shortly before 7am and police are not looking for anyone else in relation to the shooting.
It was the second car ramming incident involving police on Tuesday morning, with an officer hit in the leg by a vehicle at Mont Albert about 1am.
Several police cars had been trying to box in a stolen BMW when the driver started hitting the police cars and the leading senior constable.