Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am launching a exe in system account to log off the machine .
I am using the ExitWindowsEx APi with the adjust token .
But i am getting error as "1".(Incorrect function.)

But when i launching same exe in user account(which currently logged in ) its working fine.

Can any one help me.

I have refered the following link..
https://msdn.microsoft.com/en-us/library/windows/desktop/aa376871(v=vs.85).aspx[^]
Posted
Comments
barneyman 9-Mar-15 18:09pm    
are you trying to use an exe running in SYSTEM context to log the current (interactive) user off?

look at ImpersonateLoggedOnUser
@BangIndia 10-Mar-15 1:29am    
Yes i am running the exe in system acccount and trying to log off other accounts.
If you want to use ImpersonateLoggedOnUser then we need to user name and password.
From system account we can't get this.
is there any other way?
Mike Nordell 14-Mar-15 2:35am    
SYSTEM should have just about any privileges there are. What it hasn't got is a HANDLE to your HDESKTOP. Perhaps shutting down using that function requires a user (an actual user)?

I hope that hint will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900