Results 1 to 7 of 7

Thread: Command Line Argument Problem

  1. #1

    Thread Starter
    Lively Member trip85's Avatar
    Join Date
    Jun 2000
    Location
    Chalfont, PA
    Posts
    106

    Command Line Argument Problem

    Hello Everyone-

    I am having a problem passing in Command Line Arguments to my VB program.

    My program does not seem to recognize any parameters that I pass into it when calling the EXE or when trying to test it passing the parameters in through the IDE.

    I am using:
    VB Code:
    1. If Command$ <> "" then
    2.      'Do stuff here
    3. end if
    to determine if any arguments are being passed into my program. But no matter what I pass in as an argument the "Command$" variable always equals "". I have another program that accepts the exact same argument and I do not have any problems.

    Has anybody else ever had this problem or have any advice on what is happening?

    Thanks
    Thanks in Advance!
    TRIP85

    In the game of life, it's not whether you win or lose, it's how drunk you get.
    -Homer Simpson

  2. #2
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Sounds really weird as I don't know how you pass those args. To debug what values are comming in go to you Project Properties and set some value to "Command Line Arguments" on the "Make" tab and run your project.
    Note: your logic must be within your app's startup procedure (Form_Load or Sub Main)
    McGenius

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    This seems to work for me!!
    Attached Files Attached Files
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    This DOES work:
    VB Code:
    1. Private Sub Form_Load()  
    2.     If Command <> "" Then
    3.          MsgBox "Command!!"
    4.     End If
    5. End Sub

    This DOESN'T:
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim Command As String
    3.    
    4.     If Command <> "" Then
    5.          MsgBox "Command!!"
    6.     End If
    7. End Sub

    Check if you don't have anything like this.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  5. #5

    Thread Starter
    Lively Member trip85's Avatar
    Join Date
    Jun 2000
    Location
    Chalfont, PA
    Posts
    106
    When running the EXE I pass the arguments as follows:

    c:\Vivid\Software\EnhancedMenuGenerator.exe Headend01Days001

    And the my program will not pick up the argument.

    I also tried passing the same Headend01Days001 argument into the program using the IDE through the "Properties/Make" tab and I get the same results , the program acts as if it is not getting any arguments passed to it.

    It is really wierd because i have another piece of software that i wrote that is almost identical to the one I am working on now and it has no problem accecpting the same command line argument.
    Thanks in Advance!
    TRIP85

    In the game of life, it's not whether you win or lose, it's how drunk you get.
    -Homer Simpson

  6. #6

    Thread Starter
    Lively Member trip85's Avatar
    Join Date
    Jun 2000
    Location
    Chalfont, PA
    Posts
    106

    Here is the code that I am using:

    VB Code:
    1. If Command$ <> "" Then
    2.                                 '/* Don't allow the GeneratedTitles screen to be */
    3.                                 '/* shown if the menus are running under         */
    4.                                 '/* autmation.                                   */
    5.         MenuGenerator.chkOptions(0).Value = 0
    6.         chkAutomaticPackage.Value = 1
    7.        
    8.         MidnightDate = Format(Date, "MM/DD/YY HH:MM:SS")
    9.        
    10.                                 '/* "Command$" must be passed in the through the */
    11.                                 '/* Command Line in the following format:        */
    12.                                 '/* Headend00Days000                             */
    13.         CommandString = Command$
    14.         Days = Mid(CommandString, 14, 3)
    15.         Headend = Mid(CommandString, 8, 2)
    16.        
    17.        
    18.         If Days = 0 Then
    19.             txtBuildDate.Value = Now
    20.         ElseIf Days = 1 Then
    21.             txtBuildDate.Value = DateAdd("d", 1, MidnightDate)
    22.             txtBuildDate.Value = Format(txtBuildDate.Value, "MM/DD/YY 12:00:00") & " AM"
    23.         Else
    24.             txtBuildDate.Value = DateAdd("d", Days, MidnightDate)
    25.             txtBuildDate.Value = Format(txtBuildDate.Value, "MM/DD/YY 12:00:00") & " AM"
    26.            
    27.         End If
    28.         Call MenuGenerator.SQLQueries(adoExpirationDate, "", "", 6)
    29.        
    30.         If Headend = 0 Then
    31.             MenuGenerator.chkMultiHeadends.Value = 1
    32.         Else
    33.             MenuGenerator.chkMultiHeadends.Value = 0
    34.             HeadendCode = Headend
    35.             cboHeadends.BoundText = HeadendCode
    36.         End If
    37.        
    38.         'Call RefreshHeadends
    39.         SSTVODGenerator.Tab = 0
    40.         MenuGenerator.Show
    41.  
    42.         Call cmdGenerateVOD_Click
    43. End If

    Which is the same code that I use in another piece of software for a different customer and it doesn't have any problems.
    Thanks in Advance!
    TRIP85

    In the game of life, it's not whether you win or lose, it's how drunk you get.
    -Homer Simpson

  7. #7
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Can you post the form or project, instead?
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width