Is there a way to prevent the screen from being turned off when a laptop's lid is closed? The power-action for closing the lid is already "do nothing".
gpedit.msc and setting the Select the lid switch action options for both "on battery" and "plugged in" to "Enabled" and then restart the PC.
Computer Configuration |
Administrative Templates |
Power Management |
Button Settings | set both the "Select the lid switch action" options to
Enabled. Be sure to set the Lid switch action to a value of Take no action as well.
Be sure to fully power cycle and reboot the machine once you apply these settings
Replacing the ACPI Lid device's driver as described in this answer is the only thing that has ever solved this problem for me. It's so worth the drawbacks if you're using external displays, being able to close and open the lid without fullscreen apps crashing (e.g. old games) or messing up all the windows that you've carefully laid out on multiple monitors.
Since your operating system is saying "Do Nothing", the issue is not likely settings within the operating system. Check your system's firmware configuration. In other words, go into BIOS setup or (U)EFI setup.
Details may vary between different computers, but look for options related to screen, power, sleep, performance, or hibernate.
What's the use case for this? - answers kind of depend on that.
If this is to stop the "desktop shuffle" cause by closing the lid with an external then setting the external display as the primary helps - until you unplug it while the machine is on.
If it's the actual display You need on it might be harder as this is controlled by a hardware switch (old laptops used to have a little button at the top) possibly inside the hinge on more modern machines.
Depending on model it might be in setup menu, but equally it might be a physical power supply that disconnects as well.
I don't know how but setting up an emulated external display could well provide you with some functionality as the machine will believe it still has an active display.
If your problem is the weird refresh that happens when you open the lid : I had the same problem and found that it was coming from the driver of my graphic card (NVidia GeForce GTX 965M). I tried different version of the driver without any improvment.
The solution I found was to switch to the basic video card driver provided by Windows (you do this using the Device Manager). Now, no more weird refresh for me.
I would like to suggest Policy Plus for this answer.
Policy Plus is an open source alternative to gpedit.msc for those who don't have Professional Windows verions and I was able to follow the guide by Pimp Juice (current top answer). Be warned though, you'll have to grab the current polices by going to Help -> Aquire AMDX File in Policy.