Perovskite solar cells, representing the fourth generation of solar cell technology, have emerged as a formidable contender, surpassing their predecessors in terms of performance metrics. Capitalizing on its abundant global availability, perovskite demonstrates exceptional potential as a barrier material within solar cells. This study delves into the influence of diverse window layers on the solar cell's electrical properties. The employed device structure encompassed ZnMgO, CdS/ZnO/CdS/perovskite/MoS2. An exhaustive analysis was conducted on parameters including absorber layer thickness, window layer properties, buffer layer characteristics, as well as doping concentrations within both absorber and buffer layers. Notably, the findings underscore ZnMgO's efficacy as an optimal choice for window layers in perovskite solar cells. The incorporation of ZnMgO yielded remarkable outcomes, with a power conversion efficiency (PCE) of 22%, a fill factor (FF) of 75%, a short-circuit current (Jsc) of 26 mA/cm², and an open-circuit voltage (Voc) of 1.162V. These results signify a significant advancement in enhancing perovskite solar cell performance.