Turn on/off TV using USB-CEC Adapter (Windows Batch script)

Modified on Fri, 1 May at 12:27 AM

Turning your TV on and off using the Pulse-Eight USB-CEC Adapter or NUC-CEC Adapter can be done by running batch files that are installed automatically with libcec. This article explains how to use those batch files and how to set up automatic TV on/off during PC startup and shutdown.


Installing libcec

If you have not yet installed libcec, download the latest version from GitHub:

For full installation instructions, see: How to install libcec (Windows)


The Batch Files

Once libcec is installed, the following batch files will be available in the installation folder:

Installation folder (64-bit):

C:\Program Files\Pulse-Eight\USB-CEC Adapter\

Installation folder (32-bit):

C:\Program Files (x86)\Pulse-Eight\USB-CEC Adapter\
tv_on.cmd

Sends a power on command to the TV. Double-click to run, or call from another script or Task Scheduler.

tv_off.cmd

Sends a power off (standby) command to the TV. Double-click to run, or call from another script or Task Scheduler.

Test both files manually before setting up any automation. Double-click each file and confirm your TV responds correctly. If they do not work when run by hand, resolve this before proceeding — they will not work in any automated setup either.

If Your TV Switches to the Wrong Input

By default, libcec will attempt to detect the correct HDMI port automatically, falling back to HDMI port 1 if detection fails. If your TV switches to the wrong input when the script runs, you will need to specify the correct port number manually.

Open the relevant batch file in a text editor (right-click → Edit) and add -s -p X to the end of the last line, where X is the number of the HDMI port the CEC adapter is connected to. For example, for HDMI port 3:

-s -p 3

Save the file and test again.


Automatic TV On at PC Startup

One method is available for turning the TV on automatically when your PC starts:

Windows Commands (boot)

Uses a Windows startup command to run tv_on.cmd when the PC boots. Best for single-user machines where the TV should turn on whenever the PC starts.

CEC Adapter — How to turn your TV on when your Windows 11 PC boots using Windows Commands


Automatic TV Off at PC Shutdown

To turn the TV off automatically when shutting down your PC, create a new batch file for shutdown rather than modifying tv_off.cmd directly. This keeps tv_off.cmd available for use on its own without triggering a PC shutdown every time it is called.

Creating a Shutdown Script

Open Notepad and paste the following, replacing the path with your actual installation folder path:

@echo off "C:\Program Files\Pulse-Eight\USB-CEC Adapter\tv_off.cmd" shutdown -s -t 5

Save the file as pc_shutdown.cmd in a location of your choice.

Running this script will turn the TV off and then shut down the PC after 5 seconds. You can adjust the number of seconds to your preference — for example, -t 10 waits 10 seconds.

Do not add the shutdown command directly to tv_off.cmd. If you do, running tv_off.cmd for any reason — including from a control system or other automation — will always trigger a PC shutdown. Keep the two actions in separate files.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article