Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I access data from the command-line? 1

Status
Not open for further replies.

stefanRusterholz

Programmer
Aug 24, 2001
19
CH
My VB-App serves as kind of intermediation-application and therefore gets executed via the command-line (or better: it is planned to execute it from the commandline).
I plan to give the vb-app some arguments via the commandline. My question now is: how can I access those arguments?

many thanks in advance
Stefan Rusterholz
 
Hmm, sorry, but this hint got me nothing but a few dozens of entries - but none of them seems to cover my problem (I had a lot of entries for ADO and command-object).
But I have to tell you, that I'm not very used to VB and VB-help...

could you please be a bit more specific?
but thank you so far for your help

best regards
Stefan Rusterholz
 
Sure:

Command Function

Returns the argument portion of the command line used to launch Microsoft Visual Basic or an executable program developed with Visual Basic.

Syntax

Command

Remarks

When Visual Basic is launched from the command line, any portion of the command line that follows /cmd is passed to the program as the command-line argument. In the following example, cmdlineargs represents the argument information returned by the Command function.

VB /cmd cmdlineargs

For applications developed with Visual Basic and compiled to an .exe file, Command returns any arguments that appear after the name of the application on the command line. For example:

MyApp cmdlineargs

To find how command line arguments can be changed in the user interface of the application you're using, search Help for "command line arguments."
 
OK
Thank you very much!

I'll try that one as soon as possible.

(I'm wondering why I still can't find that entry in the help system...)
 
OK I had finally time to try it and it works great!
Now a second question: is it possible to write output back to the shell?

best regards
Stefan Rusterholz
 
Not without a lot of work. When a VB application is launched from the command line it completely disassociates itself from the console (command line window) that launched it.
 
D'oh
That doesn't sound very good :-/
Now, it seems that I have to go that way anyway - I don't see any other way.

But perhaps you know another. I'll describe you my problem:
My VB App only wrapps a call to a .dll which I have to do. I don't know how that (or any other) dll exactly works but they gave an example VB-Script. My Problem is now, that I have to access it from another language (PHP). I thought, easiest way was to take the example-VB App to read from shell and write it's response to it.
Do you know if it may be possible to access the dll itself via shell?

I'll show you, how the function is used in VB:
>private declare function decryptText Lib "decryption.dll" (ByVal Text as string, ByVal Key as string, ByVal encoded as string) as Long

If you don't know, then I was pretty happy if you could show me a start for how to write to the shell (even if it's hard).

Thank you anyway!

best regards
Stefan Rusterholz
 
Hi there.
The only way I've found of writing back to a command shell in VB is to get the handle of the window and use that.
You can write to a new window easily enough but the same one is a lot trickier as stongm says above.
Check this out

HOWTO:Obtain a Console Window Handle (HWND)
ID: Q124103

in MSDN Library

 
Hi Stefan
One way to run a VB App from the command shell and return values to the same command shell is to create a ActiveX DLL and use VBScript create an instance of it. You can run the VBScript from the command line using CScript.
Check out
which outlines this
You can use WScript.Echo &quot;SomeText&quot; to output information and WScript.Quit(<AnyNumber>) to generate return values

Hope this is what you are looking for
 
After a little research I've figured out a way of talking back to the console that launches a VB application. See thread222-189857 for more details...
 
Sorry for responding so late (week-end).
Thank you all very much. You really helped me out!
It works now very fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top