Consider the following code, which simply starts a process from VB.NET:
Public Shared Sub ShellandWait(ProcessPath As String, Optional Arguments As String = "")
'Starts a process/program and waits for it to finish before execution continues.
Using objProcess As New System.Diagnostics.Process
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.Arguments = Arguments
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
objProcess.StartInfo.ErrorDialog = False
objProcess.Start()
'Wait until the process passes back an exit code
objProcess.WaitForExit()
'Free resources associated with this process
objProcess.Close()
End Using
End Sub
If we pass in a file name for ProcessPath, say "C:\test.xml", but no program is associated with the .xml extension, Windows 10 will pop up a box asking "How do you want to open this file?"
Is there anyway to prevent Windows from opening this popup? I'd like this scenario to be handled in code instead of Windows interjecting itself.
EDIT: I don't want to find the program associated with the extension. In the majority of cases where Process.Start fails, there will be no program available to handle the file type (I just used xml as an example). My code currently warns the user that the appropriate application is not found, but the popup from Windows also shows, which I find confusing. I just want to disable the popup from showing, if possible.