Just in case some don't know, you can open and close all the windows and sunroof using the mechanical key; insert in door lock and HOLD in position to perform either operation. I do it mechanically when I want to get the windows up without turning the car on.
Obviously coding is the way to go but this is an alternative in an emergency.
2012 BMW 535i X-drive; Space Grey/Black Dakota, Fineline; Executive (Auto trunk, NAV, HiFi Prof, Lumbar, Rear Cam, SIRIUS, Voice), Technology (Blind Spot, Hi-Beam Assist, Lane Departure, Surround View), APPS, Rear heated seats, Tint.
Retired: 78 300D, 81 300SD, 87 190E, 88 Porsche 924, 89 260E, 93 300E, 97 Volvo 850, 98 E320, 03 BMW 325iT, 02 C230 Sport Coupe, 08 BMW 535i