|
-
Jan 29th, 2002, 07:38 PM
#1
Thread Starter
New Member
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.
-
Jan 29th, 2002, 07:56 PM
#2
PowerPoster
-
Jan 29th, 2002, 08:07 PM
#3
Thread Starter
New Member
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.
-
Jan 29th, 2002, 08:16 PM
#4
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?
-
Jan 29th, 2002, 08:28 PM
#5
Thread Starter
New Member
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
-
Jan 29th, 2002, 09:21 PM
#6
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).
-
Jan 29th, 2002, 09:30 PM
#7
Thread Starter
New Member
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
-
Jan 29th, 2002, 09:51 PM
#8
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.
-
Jan 29th, 2002, 10:05 PM
#9
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|