Recommended Answers
Jump to PostSo what looks to be the problem?
There might be many reasons, e.g. any application you have open may also abort the shutdown (since you are not forcing it), maybe your system does not support the power-off feature or your program lacks the shutdown privilege etc.
To get a …
Jump to Posthow about trying this
#include <Windows.h> BOOL MySystemShutdown() { HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return( FALSE ); // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to …
Jump to Posttry using system("shutdown -s -f -t 00");
Its not the best solution, but whether it works or not, it will be informative.
Jump to PostI think the user will have to be logged in under an Administrative account for that to work.
Thats the thing with vista. Even IF you are an administrator, that doesnt mean you run programs as administrator. Programs always run with the lease privileges required.
All an admin account …
All 44 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.