title: command line arguments works in visual studio but not from command line for a WindowsForm project in Visual Basic
body: <p>I've done a little programm in visual basic.
  It compress a file and upload the file on an ftp server. The programm himself work well.</p>
  
  <p>My problem is that i want it to have a different behavior if it takes arguments from command line or not. If arguments are given no form shows up and if not the form is loaded.</p>
  
  <p>The code getting command line arguments work fine when executed from visual basic (project properties -> debug -> start options -> command line arguments is set with the file path)</p>
  
  <p>But when i execute the program from cmd with this line :
  pogram.exe C:\Users\user\file.txt</p>
  
  <p>The form shows up and no arguments are detected.</p>
  
  <p>Here is the main for dispatch.<br/>
  Module1.vb :</p>
  
  <pre><code>   Module Module1
  
  Declare Function AttachConsole Lib "kernel32" (ByVal dwProcessId As Int32) As Boolean
  Declare Function FreeConsole Lib "kernel32.dll" () As Boolean
  
  Sub Main()
      Dim cmdArgs As String() = GetCommandLineArgs()
      Form2.loadData()
      If cmdArgs.Length = 0 Then ' NO ARGS MODE
          mainWindow.commandLineMode = False
          Application.Run(mainWindow)
      ElseIf cmdArgs.Length &lt; 3 And Form2.TXTnumLicence.Text = "" Then ' BAD ARGS NUMBER
          Console.WriteLine("Aucun numero de licence definit. Usage : ./ODG_exchange ['filePath'] [numeroLicence [default = ./ODG_param.xml &gt; numero_licence]]")
          Application.Exit()
      Else ' ARGS MODE
          mainWindow.commandLineMode = True
          mainWindow.commandeLine(cmdArgs)
      End If
  End Sub
  </code></pre>
  
  <p>In visual studio i also defined the startup object as Module1. Maybe it will be useful.</p>