Don't know of a simple command you can run for this, but scripting should be able to do this.
Try intercepting the Win32_PowerManagementEvent event in PowerShell or WSH. The tomshardware article has some vbscript code, but i think you'll need a case for eventtype 10 (powerstate change). StackOverflow has some ideas at How can I know when Windows is going into/out of sleep or Hibernate mode?, though you'll have to extend the idea to handle power state change instead of sleep/hibernate. You might also find some ideas in the code for the question How does one use ManagementEventWatcher to keep track of suspend/resume?
EDIT: In fact, try something like this. This is totally hacked together, so it's not pretty. Change the Echo statements to do whatever you want if change to DC or AC power is detected. Run with
Dim battery_status, prev_status
prev_status = CheckBattery
Set colMonitoredEvents = GetObject("winmgmts:\\.\root\cimv2")._
ExecNotificationQuery("Select * from Win32_PowerManagementEvent")
Set strLatestEvent = colMonitoredEvents.NextEvent
If strLatestEvent.EventType = 10 Then
battery_status = CheckBattery
If battery_status <> prev_status Then
If battery_status = 1 Then
Wscript.Echo "DC power"
ElseIf battery_status = 2 Then
Wscript.Echo "AC power"
prev_status = battery_status
Dim oWMI, items, item
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set items = oWMI.ExecQuery("Select * from Win32_Battery",,48)
For Each item in items
If item.BatteryStatus = 1 Then
CheckBattery = 1
ElseIf item.BatteryStatus = 2 then
CheckBattery = 2