TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vinayak Temgire
NA
14
3.7k
Logoff doesn't work through windows service
Aug 25 2010 8:09 AM
Dear Friends,
I am facing this problem on Windows 2003 and 2008 Server. On XP it works fine.
I have written and Windows Service that takes receives the command and executes tasks such as Logoff, Shutdown, etc.
All the commands except Logoff works fine. I tried following ways to perform the Logoff. However it didnt work.
Try 1:
Process.Start("shutdown", "-l");
Try 2:
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
ExitWindowsEx(0, 0);
Try 3:
Process _currentProcess = new Process();
_currentProcess.StartInfo = new ProcessStartInfo("shutdown", "-l -f");
_currentProcess.StartInfo.UseShellExecute = false;
_currentProcess.Start();
Try 4:
Process.Start("logoff.exe", null);
If I write a simple C# based applicatin (not Service) it works fine for all the tries that I have made.
I am facing this problem only when I put this code in Service and that to on 2003 and 2008.
Any pointers will be appriciated.
Thanks,
Vinayak.
Reply
Answers (
0
)
send filename by the Right-Click send to context menu
Drawing