When is the Mitzvah of lighting accomplished?
The Gemara (Shabbat 22b) teaches the concept of “Hadlaka Osa Mitzvah”, that is, that the Mitzvah of the Hanukkah candles is accomplished during the lighting. As an example, the Rama (O.H. 671:6) rules that if one lit the Hanukkah at a height greater than twenty Amot, which normally invalidates the Mitzvah, and then subsequently lowered it to an acceptable height, one would not have fulfilled the Mitzvah of the Hanukkah candles. This is because at the time of lighting, the parameters of the Mitzvah were not all fulfilled, namely in this case, the proper height.
Another ramification of this concept is that at the time of lighting, there needs to be sufficient oil or candle wax for the flame to burn at least thirty minutes. Therefore, if one were to light a Hanukkah that only had enough oil to burn for less than thirty minutes and then subsequently added more oil such that it could last at least thirty minutes, one would not have fulfilled the Mitzvah. Conversely, if one were to light the Hanukkah and ensured there was enough oil to last thirty minutes, but the flames somehow extinguished prematurely, one would fulfil the Mitzvah. It should be noted that this only applies if the candles were extinguished in a way that could not have reasonably been foreseen.
Another ramification involves the additional Mitzvah of publicizing of the miracle of Hanukkah. One example is if one were to light the Hanukkah near a window while the blinds were down and then later raised the blinds as the candles were burning. Although one would fulfill the Mitzvah of the Hanukkah candles and even publicizing the miracle for those inside the home, one would not have fulfilled the enhancement of publicizing the miracle to those on the outside.
Rabbi Moshe Sternbuch (Teshuvot Vehanhagot, vol. II, § 342:8) writes a novel application of Hadlaka Osa Mitzvah in which one lights a candle with an exceptionally long wick. One does not fulfill this Mitzvah in this way because at the time of lighting, only the wick is burning and there is a delay until the oil or wax starts to burn. One would need to keep the match or lighter on the wick until the flame reaches the oil or wax in order to fulfill the Mitzvah.
Summary: In order for one to accomplish the Mitzvah of the Hanukkah candles, all parameters of the Mitzvah must be fulfilled at the time of the lighting, and not afterwards.