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!

Passing parameter using Console App

Status
Not open for further replies.

claws2rip

Programmer
Dec 14, 2001
80
US
I have a DTS package that runs a Vb.Net executable program. I would like to pass a parameter from the DTS package to the Vb.Net app without having to enter the parameter in the console manually.

Every time I try to run the DTS package and vb.net app the Console appears and waits for my input. How do pass a parameter to the Console automatically without inputting it.

Thank you
 
Instead of asking for user input, can you just change your console app to look at the command line arguments you pass it? For example,if your program worked like this:

Code:
C:\>MyProgram.exe
What is your Name?: Frank
Hello Frank.

change it to

Code:
C:\> MyProgram.exe Frank
Hello Frank.
 
Right, I dont want the console to ask for user input, just to pass the argument to the app.

I tried your suggestion and unfortunately it didnt work.

I'm using the "Execute Process Task" in DTS so when I put the argument on the command line it thinks that the argument is part of the file name.
 
No, there is an option in the DTS to pass in the arguments. Its a different field.
 
Yes, in your "Execute Process Task", there is a field called "Parameters". You can also use the Return Code to check against your app's exit code to determine whether or not it failed.
 
Yes, in your "Execute Process Task", there is a field called "Parameters". You can also use the Return Code to check against your app's exit code to determine whether or not it failed. Typing the parameters after the filename would be just if you were running it on the command line.
 

I've been putting 1 in the parameter field/section because I want to pass the value 1. But instead of passing the value 1, the console just hangs there and waits for my input into the console. If I enter a value then press "enter" then the process works fine, but it relies on me entering a value in the console and pressing "enter". This is what I am trying to avoid. I just want the value to be passed without the console waiting for my input.
whats the syntax for the parameter field?



 
Did not not modify your VB.Net console application to look at the parameters instead of interactively waiting for user input?
 

I used Console.In.Readline but that didnt work
so I tried using other variations and they still didnt work.

What's the correct syntax?
 
No, ditch the whole user interactivity altogether. You want to change your app to NOT ask for input. When it loads, you can get an array of strings with Environment.GetCommandLineArgs().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top