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

  • SEARCH
  • Home
  • 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 311269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:54:34+00:00 2026-05-12T07:54:34+00:00

We have written an application that sits in the tray controlling OpenVPN as an

  • 0

We have written an application that sits in the tray controlling OpenVPN as an extension to a bigger application.

If you run openvpn.exe on command line, you can press F4 to close it. We need to do send the same keypress from C#, but you can only send string values to StandardInput.

We have been forced to kill OpenVpn to close it, and this seems to be causing BSOD every now and then on Vista…

Here is a link to my post on MSDN that also describes the issue: MSDN Forums

Does anyone know how to send special keystrokes to a Process with StandardInput?

Or maybe a workaround to close OpenVPN more cleanly?

UPDATE:

The following do not work when passed to StandardInput.Write(), F1 key is in this example:

  • ConsoleKey.F1
  • “\x70” (Hex value for F1)
  • Convert.ToChar((int)ConsoleKey.F1)

We already properly redirect the input/output, because we can successfully pass username/password to OpenVPN with no problem.

UPDATE 2: Found this on some command line option documentation for OpenVPN:

–service exit-event [0|1]
Should be used when OpenVPN is being automatically executed by another program in such a context that no interaction with the user via display or keyboard is possible. In general, end-users should never need to explicitly use this option, as it is automatically added by the OpenVPN service wrapper when a given OpenVPN configuration is being run as a service.
exit-event is the name of a Windows global event object, and OpenVPN will continuously monitor the state of this event object and exit when it becomes signaled.

The second parameter indicates the initial state of exit-event and normally defaults to 0.

Multiple OpenVPN processes can be simultaneously executed with the same exit-event parameter. In any case, the controlling process can signal exit-event, causing all such OpenVPN processes to exit.

How would I use this in C#? Is the “exit-event” signaling they are mentioning a Mutex?

  • 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-05-12T07:54:34+00:00Added an answer on May 12, 2026 at 7:54 am

    If I run OpenVPN as the following:

    "openvpn.exe --config PathToMyConfig.ovpn --service MyEventName 0"
    

    Then the following C# code causes OpenVPN to exit cleanly:

    EventWaitHandle resetEvent = EventWaitHandle.OpenExisting("MyEventName");
    
    resetEvent.Set();
    

    Props to consultutah, his comments helped quite a bit.

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

Sidebar

Related Questions

I have written a Windows application, that can take in some command line arguments
We have written an application that manages OpenVPN from the tray as an add-on
I have written a little console application that uses s#arp. I can create an
I have written an application that uses the Tinymce editor. The administrator can create
I have written an application that allows a user to create and run a
I have written an application that allows a user to define a query, run
I have written a WPF Line of Business application that has a particular sections
I have written a Java application that I would like to run inside of
I have written an application that keeps erasing my shared preference. It was always
I have written a PHP application that uses Objects heavily. Added, deleting, updating etc..

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.