This is the script that I used to use when I had failed lightbulb issues.

Feel free to update and post as a UDF if you think it would be generally useful.

 Code:
Break ON
$=SetOption("Explicit","ON")
 
; ChangeLamp.kix
;	Automated lightbulb changer
 
Dim $sLampRef, $oLamp, $oNewLamp, $oSwitch, $iLampState
 
"Please enter lightbulb maintenance reference: " GetS $sLampRef
 
$oLamp=GetObject("Lamp:/"+$sLampRef)
$oSwitch=GetObject("Switch:/"+$sLampRef)

$iLampState=$oLamp.Illuminated
$oSwitch.Toggle
$iLampState=$oLampState | $oLamp.Illuminated
$oSwitch.Toggle
 
If $iLampState 
	Select
	Case $oLamp.Type="Bayonet"
		$oLamp.Push
		$oLamp.Rotate(-90)
		$oLamp.Pull
		:GetNewLampBayonet
		$oNewLamp=CreateObject("Lamp.Bayonet")
		$oNewLamp.Push
		If $oNewLamp.IsHot
			$oSwitch.Toggle
			$=RunFingersUnderColdWater(@WKSTA)
			If $oNewLamp.Broken Goto "GetNewLampBayonet" EndIf
		EndIf
		$oLamp.Rotate(90)
	Case $oLamp.Type="Edison Screw"
		While Not $oLamp.Released
			$oLamp.Rotate(-180)
		Loop
		:GetNewLampScrew
		$oNewLamp=CreateObject("Lamp.Screw")
		While $oNewLamp.Loose
			$oNewLamp.Rotate(180)
			If $oNewLamp.IsHot
				$oSwitch.Toggle
				$=RunFingersUnderColdWater(@WKSTA)
				If $oNewLamp.Broken Goto "GetNewLampScrew" EndIf
			EndIf
		Loop
	EndSelect

	$iLampState=$oLamp.Illuminated
	$oSwitch.Toggle
	$iLampState=$oLampState | $oLamp.Illuminated
	$oSwitch.Toggle
	If $iLampState
		"Lamp successfully changed and tested"+@CRLF
	Else
		"Lamp still not working.  Please try running FixFuse.kix then retry ChangeLamp.kix"+@CRLF
	EndIf
Else
	"Lamp is OK, no need to change"+@CRLF
EndIf