Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to run a program without opening a new window  (Read 10423 times)

0 Members and 1 Guest are viewing this topic.

IMartins

    Topic Starter


    Rookie

    How to run a program without opening a new window
    « on: June 25, 2008, 04:41:15 AM »
    Hi, I'm making a program that runs simulations on MATLAB and FLUENT, one giving results to the other in turn. The problem I'm having now is that with a batch like "matlab -nosplash -nodesktop file_to_read" a new MATLAB window is opened, the same happening with FLUENT "fluent -g -i journal_file". I needed the same windows to process the calculations in sequence! I've seen in a matlab forum that maybe tracking the matlab session id, but neither they nor I have any idea how this can be done! Any ideas, please?

    Thanks,
    Isabel

    llmeyer1000



      Intermediate

      Thanked: 1
      Re: How to run a program without opening a new window
      « Reply #1 on: June 25, 2008, 08:48:15 AM »
      Type "start /?" for start help.
      " /B   Start application without creating a new window."

      Try this:
      Code: [Select]
      start "" /B "fluent -g -i journal_file"or
      Code: [Select]
      start "title" /B "fluent -g -i journal_file"
      Use any name you choose for the title, but do not skip it. It is OK to leave it blank as long as quote marks are there.(As in first example.) Otherwise CMD will get confused when it sees the quotes around the command. CMD sees the first set of quotes as the title.

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: How to run a program without opening a new window
      « Reply #2 on: June 25, 2008, 08:50:50 AM »
      If you want to start a Command Line application in the same window, I think call would be useful.

      llmeyer1000



        Intermediate

        Thanked: 1
        Re: How to run a program without opening a new window
        « Reply #3 on: June 25, 2008, 09:30:45 AM »
        If you want to start a Command Line application in the same window, I think call would be useful.

        Call ??? I don't think so.

        Code: [Select]
        call /?
        Calls one batch program from another.

        Code: [Select]
        start /?
        Starts a separate window to run a specified program or command.

        She is running a program, not a batch file!

        Try the start command I suggested earlier.

        PS:
        I forgot to credit Dias for the suggestion to always use the title, even if blank. I discovered myself, somewhat accidentally, that the start command was behaving badly without it, but it was Dias who explained the "why to do it". Thanks again DIAS.  :)

        Also, Isabel, I might add that you can sometimes run a command from a batch file without the start command and get away with it, but it is not the right way to go. You will do much better, if you follow the rules and use start every time you want to start a program from a batch file.  ;)
        « Last Edit: June 25, 2008, 09:47:35 AM by llmeyer1000 »

        Carbon Dudeoxide

        • Global Moderator

        • Mastermind
        • Thanked: 169
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Experience: Guru
        • OS: Mac OS
        Re: How to run a program without opening a new window
        « Reply #4 on: June 25, 2008, 09:31:37 AM »
        Yeah, your right.  :-X

        IMartins

          Topic Starter


          Rookie

          Re: How to run a program without opening a new window
          « Reply #5 on: June 25, 2008, 09:44:14 AM »
          Hi, thank you all for your replies. I've tried the
          start "" /B "fluent -g -i journal"
          and it gave me an error message, saying it couldn't locate "fluent -g -i journal". I've tried it again like
          start "" /B fluent -g -i journal
          but it just opens a new window an runs the journal file! Also, in the help, I saw a /D instead of a /B, but this doesn't seem to do anything! Any ideas as to why this command isn't working? It seems to be according to the syntax that DOS shows.  ???

          Isabel

          llmeyer1000



            Intermediate

            Thanked: 1
            Re: How to run a program without opening a new window
            « Reply #6 on: June 25, 2008, 09:54:33 AM »
            I've tried the
            start "" /B "fluent -g -i journal"
            and it gave me an error message, saying it couldn't locate "fluent -g -i journal".

            Is fluent located is the same folder as the batch file? I suspect it is not.
            Add the path to the command line.
            IE:
            Code: [Select]
            start "" /B "C:\Program Files\Fluent Path\fluent -g -i journal"The above path is of course just an example.  ;)

            Edit:
            I should add this. I have no idea what command line switches you should be using, but the method to start the program should be valid.

            IMartins

              Topic Starter


              Rookie

              Re: How to run a program without opening a new window
              « Reply #7 on: June 25, 2008, 10:07:20 AM »
              Hi, I've tried that too, with the complete fluent path, but it returns the same error message. DOS seem to be reading "c:\path\fluent -g journal" as an entire path to the executable, not as the executable and switches. -g just means that FLUENT is to be opened without GUI.

              Dias de verano

              • Guest
              Re: How to run a program without opening a new window
              « Reply #8 on: June 25, 2008, 10:16:10 AM »
              start "" /B "C:\Program Files\Fluent Path\fluent" -g -i journal

              Dias de verano

              • Guest
              Re: How to run a program without opening a new window
              « Reply #9 on: June 25, 2008, 10:18:31 AM »
              I needed the same windows to process the calculations in sequence!

              Do you mean that you want to invoke Matlab, and wait for it to finish, and (only) then run Fluent?

              llmeyer1000



                Intermediate

                Thanked: 1
                Re: How to run a program without opening a new window
                « Reply #10 on: June 25, 2008, 10:25:25 AM »
                start "" /B "C:\Program Files\Fluent Path\fluent" -g -i journal

                Right on Dias. Thanks. I was just about to suggest losing the quote marks. I got off track from using the quotes as Isabel posted earlier. Sorry Is!  :(

                the same happening with FLUENT "fluent -g -i journal_file"

                IMartins

                  Topic Starter


                  Rookie

                  Re: How to run a program without opening a new window
                  « Reply #11 on: June 25, 2008, 10:26:28 AM »
                  Hi, I've tried the
                  start "" "c:|path\fluent" -g journal
                  and it gives another error message, saying that it couldn't read directory c:\path\journal !  ???
                  My goal is to have MATLAB give an inicial set of conditions to FLUENT, trough a file it writes and that is loaded as the journal, and after FLUENT reads the file and executes the commands, it creates another file, that is "fed" into MATLAB, and they keep doing this in sequence for an x number of times.

                  Dias de verano

                  • Guest
                  Re: How to run a program without opening a new window
                  « Reply #12 on: June 25, 2008, 10:39:40 AM »

                  and it gives another error message, saying that it couldn't read directory c:\path\journal !  ???
                  What are the full path and filenames of the matlab and fluent executables?

                  e.g c:\program files\matlab\matlab.exe

                  IMartins

                    Topic Starter


                    Rookie

                    Re: How to run a program without opening a new window
                    « Reply #13 on: June 25, 2008, 10:45:49 AM »
                    The full path to fluent is "c:\Fluent.Inc\ntbin\ntx86\fluent.exe" ant to matlab is "C:\Program Files\MATLAB\R2007a\bin\matlab.bat".
                    I'm sorry for the constant 'it doesn't work', but I have no idea how to do this!  :-[ If I try another way, like with the wait command, I have to choose  BIG delay times, because both programs take different times to run the calculations, so the program would be VEEEEEEEERY slow! My best shot is to have each of the progrms feed the solution file to the other once it's ready! Thanks!

                    Isabel

                    BC_Programmer


                      Mastermind
                    • Typing is no substitute for thinking.
                    • Thanked: 1140
                      • Yes
                      • Yes
                      • BC-Programming.com
                    • Certifications: List
                    • Computer: Specs
                    • Experience: Beginner
                    • OS: Windows 11
                    Re: How to run a program without opening a new window
                    « Reply #14 on: June 25, 2008, 11:37:30 AM »
                    If you want to start a Command Line application in the same window, I think call would be useful.

                    Call ??? I don't think so.

                    Code: [Select]
                    call /?
                    Calls one batch program from another.

                    Code: [Select]
                    start /?
                    Starts a separate window to run a specified program or command.

                    She is running a program, not a batch file!

                    Try the start command I suggested earlier.

                    PS:
                    I forgot to credit Dias for the suggestion to always use the title, even if blank. I discovered myself, somewhat accidentally, that the start command was behaving badly without it, but it was Dias who explained the "why to do it". Thanks again DIAS.  :)

                    Also, Isabel, I might add that you can sometimes run a command from a batch file without the start command and get away with it, but it is not the right way to go. You will do much better, if you follow the rules and use start every time you want to start a program from a batch file.  ;)

                    Strange- I only use the start command when I want to load up a document from the command prompt. Why? Well, Start internally calls the ShellExecute (or ShellExecuteEx) APIs, which definitely are not the best way to execute a Program. Rather, I use their direct name, since as far as I can tell command prompt starts processes in that case with the CreateProcess API, which is must faster. So Start wins for flexibility, but if your going for speed, directly entering the name is the way to go.
                    I was trying to dereference Null Pointers before it was cool.