0

I am trying to sleep my PC using this command

system("C:\\Windows\\System32\\psshutdown -d -t 0");

it works fine if I use cmd, but when I run this in cpp, I got this

'C:\Windows\System32\psshutdown' is not recognized as an internal or external command, operable program or batch file.
0

1 Answer 1

2

32-bit applications running on 64-bit Windows will be put under file system redirection. Therefore if your app is a 32-bit one, the call system("C:\\Windows\\System32\\psshutdown -d -t 0"); will look for psshutdown.exe in C:\Windows\SysWOW64 and failed. You have some solutions:

  • Use Sysnative instead to access the real System32 folder:

    system(R"(C:\Windows\Sysnative\psshutdown -d -t 0)");
    
  • Turn off file system redirection explicitly (should be avoided in general)

  • Or better recompile your app as a 64-bit application

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.