Results 1 to 9 of 9

Thread: Command line Applications

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    5

    Command line Applications

    I require some help with a command-line app i have just finished writing.

    When i pass the parameter "/?" i wish to display the information about the application (inside the command prompt, not with msgbox), just like any other DOS based program eg MkDir, ipConfig....

    this does not seem to be as easy as i had first assumed, and any suggestions would be greatly appreciated.

  2. #2
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    VB Code:
    1. If $Command = "/?" Then
    2.       MsgBox "Help Me!!! I'm Sinking!!!!!"
    3. End If


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    5

    not quite what i was after.. but thanks

    Thanks, but i am looking for a method that does not require the use of message box... but rather works just like any other DOS based application ie. Writes to the command prompt.

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    A sample batch file that uses command line parameters is listed below: (PrintBar.bat)

    @ECHO OFF
    IF '%1'=='/?' GOTO ERROR
    IF '%1'=='' GOTO ERROR
    ECHO Insert card stock in the printer's default paper tray.
    PAUSE
    IF EXIST E:\REPORTS\%1.TRA ECHO COPY E:\REPORTS\%1.TRA LPT1: /B
    IF EXIST E:\REPORTS\%1.TRA COPY E:\REPORTS\%1.TRA LPT1: /B
    GOTO END
    :ERROR
    ECHO USAGE: PRINTBAR JOBNAME
    ECHO Where JOBNAME is the name of the PostalSoft Job
    ECHO and the associated barcode file.
    :END
    REM End of Batch file


    Was this what you were looking for?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    5

    Not really

    I'll try to explain by example..... when you run "Mkdir /?" from a command prompt, it will display a list of the applictions functionality, I want my app to do the same thing...in the same way.

    I have tried ...
    (for an app called 'NameKill')


    Shell ("Echo USAGE: NameKill processname")
    Shell ("Echo")
    Shell ("Echo Example: NameKill inetinfo.exe")

    but due to the natue of the shell function this does not work

    I have a feeling that the answer lies with some functions found in the 'Kernel32' api... for example 'WriteConsole' but am unable to use it with an existing command prompt (only works if i create a console using 'AllocConsole')

    Hope this explains my problem a little better

  6. #6
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    Lets see if I understand what you want to do:

    You want a Windows application that runs like a DOS application, in a DOS window.

    Getting the parameters from the command line is no problem.
    Making it run in a DOS (or command prompt) window will be the problem. This is why I initially supplied a batch file. You can always create a batch file with VB, then Shell to that to get this effect, but I don't know if you can do everything you want that way. It might help if you could explain exactly what function(s) you want this application to perform (besides having the capability to echo the help data).

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    5
    aside from the help data, and perhaps a few error and success messages everything else works fine ... i can just bite the bullet and use msgboxes but i was really hoping to have it work like other DOS programs

  8. #8
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    Actually, there probably is a way to get your program to display its message in a command prompt Window, but it will require using a batch file to call your program and to display any error messages or results that your program generates. Example:

    Batch file name: RunProg.bat
    VB Program name: VBProg.exe
    Results file created by VBProg.exe: VBResults.txt

    Batch file contents:

    VBProg.exe
    :CHECKTXT
    IF EXIST VBRESULTS.TXT THEN TYPE VBRESULTS.TXT
    IF EXIST VBRESULTS.TXT THEN GOTO END
    GOTO CHECKTXT
    :END
    REM End of batch file


    You could try this to see if it works.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    5
    Thanks heaps... a little messy but clever thinking!!

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