VB6-> VB.net .. problems

G

Guest

Hi,

I know VB6 pretty well but has just started to work on VB.net.

I am experiencing problems during my tests and I wonder if someone can
advise me.

Q1: I use the Shell function to run external 'console' programs. These
console programs display information on the screen while working.
Because I use the shell function, I would like to be able to grab what the
'console displays' on the screen to see if this console program works fine.
I basically tried to run something like 'c:\Consoleprog.exe > prog.txt' but
I never get the prog.txt with the shell function. It works fin in command
line.
So : Is it the best way to do what I want to do ? (I don't think so)
What is going on ?

Q2: I have a VB.net Service. This service is working fine. I would like to
create a function in my service that can be called from a script (.vbs). I
wonder what is the best and most simple option. Com ? Other ?
If you can advise me (because it is a service) and give me a sample code to
test this.

Thanks for you help.

Regards
SN
 
K

Ken Tucker [MVP]

Hi,

Answer to question 1

Dim pi As New ProcessStartInfo

Dim p As Process

pi.RedirectStandardOutput = True

pi.FileName = "c:\pubsconsole.exe"

pi.UseShellExecute = False

Dim sw As New System.IO.StreamWriter("C:\MyOutPut.txt")

p = Process.Start(pi)

sw.WriteLine(p.StandardOutput.ReadToEnd)

p.WaitForExit()

sw.Close()



Ken

------------------------------------

Hi,

I know VB6 pretty well but has just started to work on VB.net.

I am experiencing problems during my tests and I wonder if someone can
advise me.

Q1: I use the Shell function to run external 'console' programs. These
console programs display information on the screen while working.
Because I use the shell function, I would like to be able to grab what the
'console displays' on the screen to see if this console program works fine.
I basically tried to run something like 'c:\Consoleprog.exe > prog.txt' but
I never get the prog.txt with the shell function. It works fin in command
line.
So : Is it the best way to do what I want to do ? (I don't think so)
What is going on ?

Q2: I have a VB.net Service. This service is working fine. I would like to
create a function in my service that can be called from a script (.vbs). I
wonder what is the best and most simple option. Com ? Other ?
If you can advise me (because it is a service) and give me a sample code to
test this.

Thanks for you help.

Regards
SN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top