It is haram, no matter the intention, to do any form of worship that is not in the Quran or the Authentic Sunnah, to get closer to Allah. For the Prophet (May God's Blessings and peace be upon Him) said:
ما تركتُ شيئاً يقربكم إلى الله إلا وأمرتكم به
I have not left anything that will bring you closer to Allah, except that I have given it.
You may read the above Authentic Hadith, narrated by Al Tabarani, here, at exactly the 25th line count each line until you reach the 25th.
As for prostrating to idols with the intention of worshiping Allah, this is totally unacceptable and is clear, without a doubt, shirk. Allah says in Surat Azzamar Ayah 3:
Unquestionably, for Allah is the pure religion. And those who take
protectors besides Him [say], "We only worship them that they may
bring us nearer to Allah in position." Indeed, Allah will judge
between them concerning that over which they differ. Indeed, Allah
does not guide he who is a liar and [confirmed] disbeliever.