Open TCP/IPv4 dialog with visual basic button - vb.net

I have a button in visual basic. I would like, when I hit the button for it to open up the TCP/IPv4 dialog window of the active network connection on the machine so that I can quickly and easily change ip address settings.
I can't seem to find a way to google this properly. All ways I can think to ask the question return unrelated results.
How do I open this dialog window with VB code?
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
End Sub

I'm not too sure if you can get it to open up straight at the WiFi properties of the current connection, but you can get it to open the Network Connections which should be able to save you some time.
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
Process.Start("ncpa.cpl")
End Sub

You cant open it directly but this article has a method using #Werdna's approach of using ncpa.cpl and send keys.
It also has the command line utilities for extracting / setting the ip.
https://superuser.com/questions/735292/how-to-open-tcp-ip-properties-from-cmd-or-run-directly

Related

Closing main form doesn't finish process (only some computers)

The problem is happening on 2 of the company's computers and on a client computer, but we can not identify a pattern.
I was able to reproduce the error using a simple program that only opens an OpenFileDialog. The program must be run by the generated executable itself (NOT by Debug) and it is still running in the background even after closing. Below is the code of the program, along with a link to download the project and a video demonstrating the error.
Code:
Public Class Form1
Private ofdAbrir As Windows.Forms.OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ofdAbrir = New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
ofdAbrir.Dispose()
ofdAbrir = Nothing
End Sub
End Class
As you can see in the code above, I only have one form, so it is not the case that some form remains open and it is also not related to threads running since none is created.
To reproduce the problem, click on Button1, cancel the OpenFileDialog and try to close the form (clicking on X). The form apparently will close, but you will see at task manager that it still running. The big mystery is that this problem does not happens in all computers.
Video: https://drive.google.com/open?id=1sfdVUGQlwYNCQkl1Ht-cJSOb4433sqnT
Project: https://drive.google.com/open?id=1d4oJYUjaaZ9xnRj4CX3HXOQPqwMZmE0V
I couldn't reproduce the problem, but how about using this method:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Using ofdAbrir As New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
MsgBox(ofdAbrir.FileName)
End Using
End Sub
I've seen the video u posted...It is not your application that is running rather it is the vsHost.exe that is running :)...The problem shouldn't occur if u run the app outside visual studio.
If the problem is still there,just disable Enable Diagnostic Tools while debugging from Tools > Options > Debugging > Uncheck Enable Diagnostic Tools while debugging
Also u can disable Visual Studio hosting service from Project > Project Properties > Uncheck Enable the Visual Studio hosting service

Automatic login when run the program second time

Recently try to use a webbrowser component.
when I click button, it will navigate to facebook.com. after I login on first time and stop the program. and then when I run the program second time I don't need to fill the email and password. why I don't need to fill an email and password textbox ? thanks
Here's the code
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("m.facebook.com")
End Sub
End Class
Note: I will delete this post, because it doesn't help the community. Just my curiosity. Thanks
how do i need to re-type the email password again when 2nd starting the program
You have two options:
The first is to save the CookieContainer associated with the WebBrowser to disk and reload it when you restart your program. There is no straightforward way to serialize cookies to disk or other storage method - that is up to you.
Instruct the WebBrowser object to make use of the user's Windows profile Internet Explorer cookie collection which is shared with Internet Explorer and other programs that also opt-in to sharing state (I do not know if this also applies to the Edge browser, I suspect it does not). See here for instructions on how to do this: Use cookies from CookieContainer in WebBrowser

Disconnecting iTunes COM

I'm currently working with the iTunes COM with .NET, and something I came across previously, which stopped me using it, has happened again and I can't for the life of me figure it out.
When I go to close iTunes during or after my program has closed, it tells me something is still using the "Application Scripting Interface", COM is still connected.
This is what I have (removed what is not required)
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler itunes.OnAboutToPromptUserToQuitEvent, AddressOf itunes_OnAboutToPromptUserToQuitEvent
End Sub
Private Sub itunes_OnAboutToPromptUserToQuitEvent()
System.Runtime.InteropServices.Marshal.ReleaseComObject(itunes)
End Sub
So, the above code does disconnect the COM to the extent that I need to restart iTunes to use it again, but, it doesn't get rid of the Application Scripting error. Meaning, I still need to click quit after the error dialog comes up. Everything else works fine, apart from this.
Any idea?
-- I've had a look at other questions that had this issue, but none of them resolved it for me. I'm not sure if the event doesn't work anymore with this current version of iTunes, but, it doesn't seem to work currently either way.
Had same issue with COM and Office, this solved it;
While System.Runtime.InteropServices.Marshal.ReleaseComObject(itunes) <> 0
Application.DoEvents()
End While

How to make an invisible internet explorer?

I have been playing around with VB today and was wondering on the concept of being able to load a webpage in this case radio 1 online player and but having no open browsers visible to the user even though there will be one hidden one in this case this one. Currently I have it set up to simply navigate to the site but was wondering if it was possible to do what was stated above.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Dim QueryAddress As New StringBuilder()
QueryAddress.Append("http://www.bbc.co.uk/radio/player/bbc_radio_one")
Process.Start(QueryAddress.ToString())
Visible = False
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Unable to station")
End Try
End Sub
If you want to play a radio station you might be better using media player and connecting to the station's radio stream.
Drop windows media player onto your form.
Set its Visible property to False.
add a button with this code inside the button's click event
AxWindowsMediaPlayer1.URL = "http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_one.m3u8"
And of course your try..catch code as well.
Tada!
I got the url from this website by clicking on the link in the second colum and then right clicking on the data rate that I wanted and copying the linked addres. I then pasted it into the vb.net code that you see

How do I disable all exiting in Visual Basic

I'm writing an examination piece of software for my workplace and would like to know how I can trap and cancel key-presses such as:
ALT+F4
WIN+TAB
ALT+TAB
WIN
CTRL+ALT+DEL
I'm aware CTRL+ALT+DEL may not be possible, but if any of this is it'll be a step in the right direction!
Ideally I want to prevent the action, and then open a new form I've created saying 'Unauthorised keypress'
as #SQLHound link relates... us the FormClosing event to handle what happens when a user attempts to close. But if you want to block a boot attempt, then #Plutonix suggestion may help. Something along these lines...
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim splashScreen as New Form
splashScreen.OpenDialog
e.Cancel=True
End Sub