Turning off PC by its button

Good morning, i have a problem with my current project. I have to turn off my PC with arduino in certain conditions (that i already have in some if cycles), and i thought it was perfect turning it off by PC push button. That push button has 2 wires that goes straight to a connector, connected on the motherboard, there are 5V on that, and i put 2 cables (one for each cable) on the wires.

Here is the problem:
If i try to turn the computer off by digitalWrite (HIGH) on the pins of the cables the PC doesn't turn off, same with LOW, same with HIGH and then LOW (i read some post about it), same with inverted cable. If i put one wires on the ground with PC turned off, it will turn on, even if the other is not connected to arduino. If i try to do the same thing with the other one the computer will not start.

Can someone help me?

I see two issues here - the first is the switch issue. I think a small relay would probably be the best for that both for the isolation as well as being able to handle whatever they are doing with those two pins and it could then work for different PC's that may not be using the same voltages/signals on the pins.

The other concern though, depending on the OS, most operating systems do NOT take kindly to simply being turned off - strange things can happen to data especially if they are busy writing to the disk etc. Look into telling the OS to "shut down" instead - you may need to either write or find a utility that can monitor something and shut it down when something happens via a call to the OS.

gpsmikey:
The other concern though, depending on the OS, most operating systems do NOT take kindly to simply being turned off - strange things can happen to data especially if they are busy writing to the disk etc. Look into telling the OS to "shut down" instead - you may need to either write or find a utility that can monitor something and shut it down when something happens via a call to the OS.

Assuming we're talking about the power button on the front and not a power switch in the back it can usually be set up (at least in Windows) to properly shutdown when that button is pressed. It is in the control panel under power options or something like that. You decide whether the power button runs shutdown or hibernate or sleep. To just kill power (like when it's locked up) you usually have to hold that button down for a few seconds.

Delta_G:
Assuming we're talking about the power button on the front and not a power switch in the back it can usually be set up (at least in Windows) to properly shutdown when that button is pressed. It is in the control panel under power options or something like that. You decide whether the power button runs shutdown or hibernate or sleep. To just kill power (like when it's locked up) you usually have to hold that button down for a few seconds.

That's right, i have to "hold via software" the power button that is connected on the motherboard. Obivously it's the front power button (push-button). It has 2 pins.

It's a Windows PC, and i have to shut it down when arduino, with a thermistor, see that the temperature is not the operative one. I also controlling a PWM fan to cool it down.
But i don't know how to do, i have tried to set 2 pins on HIGH and put 2 jumpers on power button cables, but it didn't work.

So is the only solution a relay?

First measure the voltages on both switch terminals when inactive and also when its pressed.

The problem with invoking an orderly shutdown on Windows - either by a brief press of the power button or a program command - is that the process is easily baulked by running programs which expect to be told how to save current data.

So far, the OP has identified which is the control wire, and which is the ground. The control wire needs to be strongly pulled to ground and clearly the Arduino is of itself, incapable of this.

You need to take a general purpose NPN transistor rated at 500 mA or so, connect its emitter to the identified ground wire (which also needs to be connected to Arduino ground) and its collector to the control wire. Its base is then controlled by an Arduino pin via a 220 Ohm resistor, pulled HIGH to switch on the transistor and effectively "press" the button - for either one second to invoke the safe shutdown procedure, or five seconds to directly shut down the machine.