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:estoto.txt
The line is well executed meaning that I can find the file toto.txt in the filepath indicated.
Finally I tried with the command ShellExecuteW() as follows but without any sucess (nothing happens):
ShellExecuteW(NULL, L"runas", L"cmd.exe", L"/S /C " "batchfile path"", NULL, 0);
Now I don't know what to do in order to shutdown remote Pcs from my C++ programm.
Can anyone help me please ?
Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…