Running programs that are outside my own

the objective is to make a menu for a autorun CD that once clicked on an item runs a particular .exe file separate from my own. the file is very old dos file made from .bas with QB7.1 but i got it to work with the command "System.Diagnostics.Process.Start()" though it doesn't show the PRINT as this:

prog inputs:

dia#:

Mes#:

ano#

But does't show nor this print for input nor the result print:

the screen is black but if you press the keys it goes to next line as if it was working but not showing.

Any sugestions

Thank you,

JDuarte.



Answer this question

Running programs that are outside my own

  • jdevito

    hmm

    is this a winforms or a console application in VB.NET

    for a console, to display output to the Console Window, you would do a write to it:

    Console.Write("text")

    can you post some code you already have to help us help you



  • Jeanvo

    If I understand this correctly... the .exe works when executed from the command line (or Windows Explorer), but not with Process.Start() Does it require any parameters for you to supply

    Andrej



  • ks2006

    See my post at this link: (2nd page)

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=185278&SiteID=1&PageID=1

    and see if it helps any.



  • John Cogan

    Use the ProcessStartInfo Class to redirect the output of your application



  • furjaw

    iey! you won the contest!!! lol ! the code works... though its kind of... BIG! and do you had to leave all those lines of code separated cant' you leave them intact
    Oh and i ignored that panel1 thing ... i had no use for it! and my VBExpress2005 doesn't recognize it . thanks anyway now have to copy it to another 79 progs(dif files same directory). (any sugestion on how to make it shorter or an alias that alters variables )

    JUST ANOTHER QUESTION:
    i wanna run the prog from a CD wath is the path i use ' I have never done a softw 4 cd b4.

    this is what i had:

    Dim theProcess As New ProcessStartInfo("pdatadj.exe")

    theProcess.RedirectStandardOutput = True

    theProcess.RedirectStandardError = True 'may need to redirect errors too

    theProcess.UseShellExecute = False

    Process.Start(theProcess)


    this is the .bas file (use qb7.1 to converto to .exe):
    -------------------------------------------------------------------

    1 REM PROGRAM PDATADJ
    2 REM ROTINe DATADJ
    3 REM description portuguese->"Calcula, em calend rio juliano (at 4/10/1582), e em
    4 REM calend rio gregoriano (ap¢s 15/10/1582), dia juliano,
    5 REM data e s culos julianos desde 1900 Janeiro 0.5 TU em
    6 REM tempo universal e em tempo din mico terrestre, dia da
    7 REM semana, diferen a de tempo din mico e tempo sideral
    8 REM m dio Greenwich …s 0 horas TU
    9 REM DJ, DJ19, S, SD, DIASE, DTE, T0"/description

    10 INPUT "DIA#="; DIA#
    12 INPUT "MES#="; MES#
    14 INPUT "ANO#="; ANO#
    16 GOSUB 1000: IF ER(1) = 1 THEN GOTO 79
    18 DJ19# = INT(1E+10 * DJ19# + .5) / 1E+10
    20 IF DJ19# >= 0 THEN GOTO 24
    22 DJ19# = -INT(1E+10 * (-DJ19#) + .5) / 1E+10
    24 DJ# = INT(1E+10 * DJ# + .5) / 1E+10
    26 IF DJ# >= 0 THEN GOTO 30
    28 DJ# = -INT(1E+10 * (-DJ#) + .5) / 1E+10
    30 HT0# = INT(T0#): MT0# = INT((T0# - HT0#) * 60)
    32 ST0# = ((T0# - HT0#) * 60 - MT0#) * 60
    34 ST0# = INT(100 * ST0# + .5) / 100
    36 T0# = INT(1E+08 * T0# + .5) / 1E+08
    38 S# = INT(1E+10 * S# + .5) / 1E+10
    40 IF S# >= 0 THEN GOTO 44
    42 S# = -INT(1E+10 * (-S#) + .5) / 1E+10
    44 SD# = INT(1E+10 * SD# + .5) / 1E+10
    46 IF SD# >= 0 THEN GOTO 50
    48 SD# = -INT(1E+10 * (-SD#) + .5) / 1E+10
    50 HDTE# = INT(DTE#): MDTE# = INT((DTE# - HDTE#) * 60)
    52 SDTE# = ((DTE# - HDTE#) * 60 - MDTE#) * 60
    54 SDTE# = INT(100 * SDTE# + .5) / 100
    56 DTE# = INT(1E+08 * DTE# + .5) / 1E+08
    58 IF DTE# > 0 THEN GOTO 68
    60 HDTE# = -INT(-DTE#): MDTE# = -INT((-DTE# + HDTE#) * 60)
    62 SDTE# = -((-DTE# + HDTE#) * 60 + MDTE#) * 60
    64 SDTE# = -INT(100 * (-SDTE#) + .5) / 100
    66 DTE# = -INT(1E+08 * (-DTE#) + .5) / 1E+08
    68 PRINT "DJ# DJ19#="; DJ#; DJ19#
    70 PRINT "S# SD#="; S#; SD#
    72 PRINT "DIASE# ="; DIASE#
    74 PRINT "DTE# HDTE# MDTE# SDTE#="; DTE#; HDTE#; MDTE#; SDTE#
    76 PRINT "T0# HT0# MT0# ST0#="; T0#; HT0#; MT0#; ST0#
    78 SLEEP
    79 END

    997 REM
    998 REM ROTINe DATADJ
    999 REM
    1000 IF MES# < 3 THEN MES# = MES# + 12: ANO# = ANO# - 1
    1002 IF ANO# > 1582 THEN GOTO 1014
    1004 IF ANO# < 1582 THEN GOTO 1016
    1006 IF ANO# = 1582 AND MES# < 10 THEN GOTO 1016
    1008 IF ANO# = 1582 AND MES# = 10 AND DIA# < 5 THEN GOTO 1016
    1010 IF MES# > 10 OR DIA# >= 15 THEN GOTO 1014
    1012 ER(1) = 1: PRINT " DATA INEXISTENTE ": RETURN
    1014 A# = INT(ANO# / 100): B# = 2 - A# + INT(A# / 4)
    1016 C# = INT(365.25 * ANO#) - 694025
    1018 IF ANO# < 0 THEN C# = -INT(365.25 * (-ANO#) + .75) - 694025
    1020 D# = INT(30.6001 * (MES# + 1))
    1022 DJ19# = B# + C# + D# + DIA# - .5: DJ# = DJ19# + 2415020
    1024 S# = DJ19# / 36525: S0# = S# - (DIA# - INT(DIA#)) / 36525
    1026 A# = .0513369072# * (S0# - 1) + 2400 * ((S0# - 1) - (ANO# - 2000) / 100)
    1028 B# = 6.697374558# + (S0# - 1) * (S0# - 1) * .00002586222#
    1030 T0# = A# + B# - 1.722E-09 * (S0# - 1) * (S0# - 1) * (S0# - 1)
    1032 IF T0# > 24 THEN T0# = T0# - 24: GOTO 1032
    1034 IF T0# < 0 THEN T0# = T0# + 24: GOTO 1034
    1036 IN# = INT((DJ# + 1.5 - DIA# + INT(DIA#)) / 7)
    1038 FR# = ((DJ# + 1.5 - DIA# + INT(DIA#)) / 7 - IN#) * 7
    1040 DIASE# = INT(FR# + .5) + 1: IF DIASE# > 7 THEN DIASE# = DIASE# - 7
    1042 A1# = -98.28: B1# = 32.27: C1# = 39.367
    1044 A2# = 857.31: B2# = 842: C2# = 206.67
    1046 A3# = -8.617: B3# = -37.6: C3# = -14.237
    1048 A4# = 1.364: B4# = 64.4
    1050 IF S# < -2.8 THEN DT# = A1# + B1# * S# + C1# * S# * S#
    1052 IF S# < -2.2 AND S# >= -2.8 THEN DT# = A2# + B2# * S# + C2# * S# * S#
    1054 IF S# < -.1 AND S# >= -2.2 THEN DT# = A3# + B3# * S# + C3# * S# * S#
    1056 IF S# >= -.1 THEN DT# = A4# + B4# * S#
    1058 DTE# = DT# / 3600: SD# = S# + DTE# / 24 / 36525
    1060 RETURN




  • Speedie

  • bombfrog

    Humor me if you will.

    Try your program with the code I provided in the link. (Read all the comments)

    Keep the StartInfo.FileName as "cmd.exe" as shown.

    Set the StartInfo.WorkingDirectory to point to your exe location.

    Change

    Dim MyProgName As String = "edit.com"

    to your exe program name.

    Keep all other StartInfo settings shown in the example.

    Then, tell me what happens.



  • Amde

    I took the liberty to adapt and RESUME your code there's a lot of crap i don't need and a didn't kill function to remove the horrible dos windows after and all my progs are DOS so removed the if and declarations too; so this became it:
    preety simple actually! just a couple a dos commands and a sleep thread beetween the start and kill.

    Dim MyProgName As String = "pdatadj.exe"

    Dim p As New Process

    p.StartInfo.FileName = "cmd.exe"

    p.StartInfo.WorkingDirectory = ("MYDIR")

    p.StartInfo.Arguments = "/k " & MyProgName

    p.Start()

    System.Threading.Thread.Sleep(265)

    p.Kill()



  • dgolds

    Also, you're not doing any redirecting of stdout in your VB program are you

  • bilalso

    No the pro doesn't require any special arguments or options in windows i just run the .exe file and it opens a dos window with the prog. but when i use the command i wrote in my 1st post the print on the dos window doesnt show. (i wonder if it is needed some kind of verbose mode )

  • Rafet

    Just asking a few questions.

    Does the old compiled basic program whatever.exe run visually okay

    when launched from a cmd window (No use of Visual Basic)

    Did I describe the old program correctly. (Completely compiled into an

    executable with no other dependancies )



  • Bwilhite

    yes the .exe runs fine "standalone" and in cmd window and has no dependencies and my vb proj has no extras it's just a menu! click and run the prog.

  • Running programs that are outside my own