Windows App and Console App

  • Thread starter Thread starter deerslayer
  • Start date Start date
D

deerslayer

I want to write a small VB program to run an existing console application
from windows. I want to do this to make running the existing application
easier and set options and file paths. As far as I can tell, my program
will need to run both a windows form application (to chose and enter the
options and file paths) and a console application (to run the existing
application ex, "Shell ("C:\existingapp.exe " & options & path)"). I have
VB Express and I'm just learning. If anyone has some suggestions as to how
to go about this I'd appreciate it. I don't believe this will be a
complicated program, I just don't know how to handle the console part of it.
Thanks.
 
I want to write a small VB program to run an existing console application
from windows.  I want to do this to make running the existing application
easier and set options and file paths.  As far as I can tell, my program
will need to run both a windows form application (to chose and enter the
options and file paths)  and a console application (to run the existing
application ex, "Shell ("C:\existingapp.exe " & options & path)").  I have
VB Express and I'm just learning.  If anyone has some suggestions as tohow
to go about this I'd appreciate it.  I don't believe this will be a
complicated program, I just don't know how to handle the console part of it.
Thanks.

Use the Process class in the windows forms app to launch the console
app.
 
Use the Process class in the windows forms app to launch the console
app.

Can you give me an example? I tried Process.Start("C:\existingapp.exe") but
doing so didn't work properly. I think existingapp.exe did run but there
was only a brief flash of the console and then it disappeared. Is there a
way to make the console stay visible?
 
Use the Process class in the windows forms app to launch the console
app.



here a code snipit:

Sub Main()
Dim myProcessInfo As New ProcessStartInfo

myProcessInfo.Arguments = ""
myProcessInfo.FileName = "C:\Program Files\Microsoft
Office\Office12\excel.exe"

REM start proccess
Process.Start(myProcessInfo)
End Sub



-Nex6
 
Nex6 said:
here a code snipit:

Sub Main()
Dim myProcessInfo As New ProcessStartInfo

myProcessInfo.Arguments = ""
myProcessInfo.FileName = "C:\Program Files\Microsoft
Office\Office12\excel.exe"

REM start proccess
Process.Start(myProcessInfo)
End Sub

-Nex6

Thanks I got that but the difference is that excel.exe is not a program that
runs only in the console as is the program I'm trying to run (see original
post). Doing the above with the existing console.exe program flashes the
console and quickly disappears. I'd like to know how to maintain the
presence of the console until the user releases it with a "press any key" or
something similar.
 
Thanks I got that but the difference is that excel.exe is not a program that
runs only in the console as is the program I'm trying to run (see original
post).  Doing the above with the existing console.exe program flashes the
console and quickly disappears.  I'd like to know how to maintain the
presence of the console until the user releases it with a "press any key"or
something similar.

If you want the process running the console app to wait for a key
press, then the exe running the console app has to do that. So, make a
command file with two lines:

<path to you console app exe>
pause Press any key

And run that command file in your Process. There is some special
syntax to run a command file instead of an EXE and I don't have access
to it right now, but you should be able to google it.
 
If you want the process running the console app to wait for a key
press, then the exe running the console app has to do that. So, make a
command file with two lines:

<path to you console app exe>
pause Press any key

And run that command file in your Process. There is some special
syntax to run a command file instead of an EXE and I don't have access
to it right now, but you should be able to google it.

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/0733fde9-8eac-4487-b76f-14814d5a28a9/
 
The only thing the sample code does is starting the excel.exe from a
console. In fact a kind of shortcut.

Try something to do with the console.read before you start the application,
in that way you get the parameters you enter in your console

However, be aware that a console program is not a kind of communitation
program. You start only a program using the cmd.

In the arguments are the arguments you are passing to the program.

It sounds a little bit weird what you want (a kind of Dos.Bat file or
something)

Cor
 
What I've got is contig.exe (from technet.microsoft.com) which is a defrag
utility that runs only from a console. I wanted to write a windows front
end to input options and the file path (cumbersome to do in a console) and
then run the application. I'm new to VB and this seemed a reasonable
project to take on. Not dos.bat at all.
 
What I've got is contig.exe (from technet.microsoft.com) which is a defrag
utility that runs only from a console. I wanted to write a windows front
end to input options and the file path (cumbersome to do in a console) and
then run the application. I'm new to VB and this seemed a reasonable
project to take on. Not dos.bat at all.

As pointed out in other replies, you need to use the Process class to
start your command line app. You said that the app just flashes and
disappears. Are you sure you are passing the correct command line
parameters? As Nex6 points out, make sure you set the Arguments
property of the ProcessStartInfo object correctly. And check out the
other properties of the Process and ProcessStartInfo classes.

Chris
 
Since perhaps VB1 around 15 years ago, you can use the single quote char <'>
instead of REM.
yea, i know and using both REM and the tick '

i mix and match, since both are supported :)

in larger codebased REM are used for things i mean to remove, and ticks
are for stuff that will stay.


-Nex6
 
deerslayer said:
I want to write a small VB program to run an existing console application
from windows. I want to do this to make running the existing application
easier and set options and file paths. As far as I can tell, my program
will need to run both a windows form application (to chose and enter the
options and file paths) and a console application (to run the existing
application ex, "Shell ("C:\existingapp.exe " & options & path)"). I have
VB Express and I'm just learning. If anyone has some suggestions as to how
to go about this I'd appreciate it. I don't believe this will be a
complicated program, I just don't know how to handle the console part of it.
Thanks.

Answered in comp.lang.basic.visual.misc
 
As pointed out in other replies, you need to use the Process class to
start your command line app. You said that the app just flashes and
disappears. Are you sure you are passing the correct command line
parameters? As Nex6 points out, make sure you set the Arguments
property of the ProcessStartInfo object correctly. And check out the
other properties of the Process and ProcessStartInfo classes.

Chris

The existing console app (console.exe) that I'm trying to run from a VB
Windows Application just flashes when its run unless I run it from within an
already open console. I see the same behavior when I run it from a VB
Windows Application. The question is, how do I get the console to stay open
when initiated from a VB Windows Application?
I can accomplish this in a VB Console Application. I can run Console.exe
from a VB Console Application, Shell("console.exe"), and using a simple
Console.ReadKey(), get the console to remain open. I can't take this same
approach in a VB Windows Application.
I suppose one solution might be to run the VB Console Application from a VB
Windows Application. Can I do that and pass parameters gathered in the VB
Windows Application to the VB Console Application (and so ultimately pass
those parameters to Console.exe)?

Again, I'm new at VB.net.
 
http://www.vb-tips.com/StartProcess.aspx




deerslayer said:
The existing console app (console.exe) that I'm trying to run from a VB
Windows Application just flashes when its run unless I run it from within
an already open console. I see the same behavior when I run it from a VB
Windows Application. The question is, how do I get the console to stay
open when initiated from a VB Windows Application?
I can accomplish this in a VB Console Application. I can run Console.exe
from a VB Console Application, Shell("console.exe"), and using a simple
Console.ReadKey(), get the console to remain open. I can't take this same
approach in a VB Windows Application.
I suppose one solution might be to run the VB Console Application from a
VB Windows Application. Can I do that and pass parameters gathered in the
VB Windows Application to the VB Console Application (and so ultimately
pass those parameters to Console.exe)?

Again, I'm new at VB.net.
 
deerslayer said:
I want to write a small VB program to run an existing console application
from windows. I want to do this to make running the existing application
easier and set options and file paths. As far as I can tell, my program
will need to run both a windows form application (to chose and enter the
options and file paths) and a console application (to run the existing
application ex, "Shell ("C:\existingapp.exe " & options & path)"). I have
VB Express and I'm just learning. If anyone has some suggestions as to how
to go about this I'd appreciate it. I don't believe this will be a
complicated program, I just don't know how to handle the console part of it.
Thanks.
Check this out: http://msdn.microsoft.com/en-us/bb964686.aspx

It's sample applications including (in the VB Samples\Application
Samples\ConsoleApps folder) there is an short example where input/output
is feed to/from the command line. The final product (build) is a console
app, which I don't think you're looking for, but it was a good example.

Comes complete with sln so you can pop it in to VS/VS Express and play
with it.


Cheers.
 
RW said:
Check this out: http://msdn.microsoft.com/en-us/bb964686.aspx

It's sample applications including (in the VB Samples\Application
Samples\ConsoleApps folder) there is an short example where
input/output is feed to/from the command line. The final product
(build) is a console app, which I don't think you're looking for, but
it was a good example.

Comes complete with sln so you can pop it in to VS/VS Express and play
with it.

Cheers.

Thanks. I'll look into it.
 
Back
Top