Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8786619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:40:54+00:00 2026-06-13T21:40:54+00:00

I want to make auto logoff while closing the winform without timer access. How

  • 0

I want to make auto logoff while closing the winform without timer access. How do I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:40:55+00:00Added an answer on June 13, 2026 at 9:40 pm

    I do not really understand what do you mean by without timer access but you may run a process or a command while the form is closing using the FormClosing event.

    If you would like to log off the user when the form is about to close, you may try to use the executable file shutdown.exe as a process and its argument /l

    Example

    public Form1()
    {
        InitializeComponent();
        this.FormClosing += new FormClosingEventHandler(Form1_FormClosing); //Link FormClosing event to Form1_FormClosing
    }
    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        Process logoff = new Process(); //Initialize a new process
        ProcessStartInfo ProcessInfo = new ProcessStartInfo(); //Initialize a new ProcessStartInfo
        ProcessInfo.FileName = "shutdown.exe"; //Set the FileName of ProcessInfo
        ProcessInfo.Arguments = "/l"; //Log off, see 'shutdown.exe /?' for more information
        //ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden; //Hide the process window (not required)
        logoff.StartInfo = ProcessInfo; //Associate ProcessInfo with logoff.StartInfo
        logoff.Start(); //Start the process
    }
    

    This will start the executable file shutdown.exe as a new process with its arguments /l which means log off the current user

    Notice that: FormClosing is fired when the form is about to close. You may stop the form from closing by setting e.Cancel to true

    Example

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        e.Cancel = true; //Don't close the form
    }
    

    Thanks,

    I hope you find this helpful 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a Greasemonkey script that auto-clicks the Empty trash link every
I want to make an auto synchronize in my application that will happen every
I want to develop a facebook application that make auto post to a facebook
I want to make a searchbox which has auto suggestion and searches specific tag
i want to make the height of the aspx page auto. So i have
I want to make SVN ignore everything that is in my wordpress directory. It
I want to make an SMS scheduling app, that sends SMS at predefined time.
hey all i want to make an auto login after successful registration in spring
I have a directory that contains thousands of subfolders. I want to make it
I want to make an scrollable div that scrolls down when the user hovers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.