How to run a batch file in order to shutdown PC from C++ service on a Windows 10 machine?
问题 I have a C++ program that runs as a service on a 64-bit Windows 10 machine. In this program, I want to execute a batch file to remotely switch off Pcs. I tried to use the function system() as follows : system("cmd.exe /C \"batchfile path""); system("shutdown /s /f /t 15 /m IPAdress"); In the second case, nothing happens. And in the first case, when I put a shutdown in my batch file, nothing happens however when I put a line like : echo Test >> D:\test\toto.txt The line is well executed