1

I am able to

  1. shut down a remote computer via shutdown /s /m \\\MachineName; and

  2. cut that remote computer's power supply (think power switch with IP featuring TelNet communication).

I want to execute both tasks sequentially, but for obvious reasons Task 2 should not be invoked before Task 1 has succeeded completely.

Both tasks are executed within an application (VB6). They run as intended, individually. But serially, I need to reliably find out when the remote machine has been shut down completely, before doing Task 2.

So the question is: how can I reliably detect termination of Task 1? Is it even possible? For example, could I use a shell script?

Timing Task 1 is not an option: it can run for an unpredictable duration (think Windows updates, "don't switch off this machine until finished").

17
  • 5
    You cannot. At some point, windows disables the network and from that moment you simply can't know from the pc itself if its still on or not. If your power switch can measure how much voltage is being drawn (A UPS can) then you can measure the voltage and once it reaches 0, you will know the pc is powered off.
    – LPChip
    Commented May 10, 2017 at 11:27
  • 1
    @LPChip: interesting idea, but that would assume an UPS for each individual computer. Albeit there are 3 such devices here, they do cover plenty of electrical stuff (multi-room-based). And there are more than 3 computers here. Shouldn't I be able to at least Ping a computer during its Windows update? After all, the update comes from the Internet.
    – Herb
    Commented May 10, 2017 at 11:42
  • 1
    No, the update is downloaded when you are still in windows. Windows then shuts down and exits the kernel. Outside of windows, the updates are installed. This is required so the update can alter files that are otherwise in use. I used UPS as example. There are powerbricks that can be network controlled too. There must be one that can read the wattage of all devices.
    – LPChip
    Commented May 10, 2017 at 11:53
  • 1
    You may be able to detect the presence of power on an external interface, eg certain motherboards have BIOS settings of which interfaces maintain power when the computer is off. If there is an HDMI interface, this will normally lose any power from its control lines.
    – AFH
    Commented May 10, 2017 at 12:02
  • 2
    If this is important, get a computer with a baseboard management controller, then user SNMP to monitor the system's Power On state. BMC controllers operate "out-of-band" and can report on the system's state without a running OS or even the machine being powered on. Commented May 10, 2017 at 12:49

1 Answer 1

4

You cannot.

At some point, windows disables the network and from that moment you simply can't know from the pc itself if its still on or not. If your power switch can measure how much voltage is being drawn (A UPS can) then you can measure the voltage and once it reaches 0, you will know the pc is powered off.

To clarify how windows updates work; the update is downloaded when you are still in windows. Windows then shuts down and exits the kernel. Outside of windows, the updates are installed. This is required so the update can alter files that are otherwise in use. I used UPS as example. There are powerbricks that can be network controlled too. There must be one that can read the wattage of all devices.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .