I found possible to use CMD window to start typical NET GUI application.
But not so clean, with some issues.
Here is my example code:
Public Class main_form
Private Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
Private Declare Function FreeConsole Lib "kernel32.dll" () As Boolean
Dim mykey As String = "A01F-FFB4-0402"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Application.CommandLineArgs.Count > 0 Then
If AttachConsole(-1) Then
Dim kill_Me As Boolean = False
Dim cArgs() As String = GetCommandLineArgs()
For c As Integer = 0 To cArgs.Length - 1
cArgs(c) = cArgs(c).ToLower()
If cArgs(c) = "getkey" Then
Console.WriteLine(mykey)
kill_Me = True
End If
Next
FreeConsole()
If kill_Me Then End
If (MessageBox.Show( _
"Asked command not present." & NewLine & "Start program with GUI normally?", "", _
MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = _
DialogResult.Cancel) _
Then End
End If
End If
Please ignore security issues, this is just an example. Like people here concludes problem is in terminating console. Here are approach with sending key "ENTER" to it but this is obviously not good solution.
If I start example program from CMD window with: c:\mydir>myprogram.exe getkey|more then console behaves more "natural" than without switch "more".
1) But, if I start a program with c:\mydir>myprogram.exe getkey: is it possible with VBNET to add keyword "|more" to commandline argument "getkey" before execution so program will execute "getkey|more" instead of only "getkey"?
2) Is it acceptable to terminate GUI program with just command "End" in form's _Load handler like is showed in example? I try Application.Exit() and Me.Close() where program don't behaves well.