Advertisement
netrosly

OpenVPN Vb.net

Jun 15th, 2015
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.86 KB | None | 0 0
  1. '*Make sure to have all your server files in the debug folder Wink
  2.  
  3. 'Code:
  4. If ComboBox1.Text = "ServerName" Then
  5.     System.Diagnostics.Process.Start("openvpn-gui.exe", "--connect openvpnserver.ovpn")
  6. End If
  7.  
  8. 'How to Hide the OpenVPN window and make it run in the background
  9.  
  10. 'Code:
  11. Dim style As Integer = GetWindowLong(hWnd, GWL_STYLE)
  12. style = style And Not (WS_VISIBLE)
  13.  
  14. style = style Or WS_EX_TOOLWINDOW
  15. style = style And Not (WS_EX_APPWINDOW)
  16.  
  17. ShowWindow(hWnd, SW_HIDE)
  18. SetWindowLong(hWnd, GWL_STYLE, style)
  19. ShowWindow(hWnd, SW_SHOW)
  20. ShowWindow(hWnd, SW_HIDE)
  21.  
  22.  
  23. 'How To Kill The Process So its only open 1 time and you dont get the error "openvpn gui is already running"
  24. 'Code:
  25. For Each namehere As Process In Process.GetProcesses
  26.       If namehere.ProcessName.Contains("OpenVPN") Then
  27.                  namhere.Kill()
  28.  
  29.      End If
  30. Next
  31. 'not by me ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement