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

Author Topic: make [ Batch file to execute program ]  (Read 12278 times)

0 Members and 1 Guest are viewing this topic.

raygra

    Topic Starter


    Rookie

    make [ Batch file to execute program ]
    « on: January 30, 2009, 05:31:42 AM »
    Hi

    I would like a batch script,
    when i start the test.bat file that locate in map/ folder called "Automatic"
    it will do the following:

    1. open paint (that are locate in the map/ folder called " Automatic ")
    2. after paint is opened, if move picture1.jpg to map/folder called  "recover" that is locate in map "Automatic"
    3. When the paint program is closed, move  picture1.jpg back to map/folder "AUtomatic"

    Note: I used the batch commando " Call "
    But is won't work in a sequence 1.2.3  here is my batch script:

    it run in a: 2.1.3 sequence 
    ------------------------------------------------------------------------
    @echo off
    cls

    MOVE picture1.jpg recover

    Call paint.exe

    move recover\picture1.jpg ..\automatic

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

    Thank you for helping 
    Sorry for my English

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: make [ Batch file to execute program ]
    « Reply #1 on: January 30, 2009, 05:37:51 AM »
    Check for an answer in the programming section.

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    raygra

      Topic Starter


      Rookie

      Re: make [ Batch file to execute program ]
      « Reply #2 on: January 30, 2009, 05:46:32 AM »
      Usng call with an exe file has no effect. Call is strictly for calling another batch program or an in-line subroutine.

      Code: [Select]
      @echo off
      cls
      [b]MOVE picture1.jpg recover[/b]
      start /wait paint.exe picture1.jpg
      move recover\picture1.jpg ..\automatic

      MSPaint runs in it's own window. The start /wait will prevent the window running your batch file from continuing until paint has finished processing.

      Good luck.  8)

      Thank you so much for your quick reply pal. Assome ;)
      The script work excellent.

      Is it possible to delay the script
      (    MOVE picture1.jpg recover       )with 15 sec



      devcom



        Apprentice

        Thanked: 37
        Re: make [ Batch file to execute program ]
        « Reply #3 on: January 30, 2009, 05:56:10 AM »
        Code: [Select]
        ping -n 1 -w 15000 1.1.1.1 >nul
        insert this and it will delay code for 15 sec
        Download: Choice.exe

        raygra

          Topic Starter


          Rookie

          Re: make [ Batch file to execute program ]
          « Reply #4 on: January 30, 2009, 06:02:38 AM »
          @echo off
          cls

          ping -n 1 -w 15000 1.1.1.1 >nul
          MOVE picture1.jpg recover
          start /wait paint.exe picture1.jpg
          move recover\picture1.jpg ..\automatic

          is does delay the whole script.
          but i would like to delay  --- MOVE picture1.jpg recover  ---- only with 15 sec.

          devcom



            Apprentice

            Thanked: 37
            Re: make [ Batch file to execute program ]
            « Reply #5 on: January 30, 2009, 06:38:35 AM »
            you want to delay MOVE so paint can start before file will MOVE ?
            Download: Choice.exe

            raygra

              Topic Starter


              Rookie

              Re: make [ Batch file to execute program ]
              « Reply #6 on: January 30, 2009, 07:05:48 AM »
              That's right :D

              devcom



                Apprentice

                Thanked: 37
                Re: make [ Batch file to execute program ]
                « Reply #7 on: January 30, 2009, 07:27:43 AM »
                batch dos not support multitask so you need to files

                BatFile1.bat
                Code: [Select]
                @echo off
                ping -n 1 -w 15000 1.1.1.1 >nul
                MOVE picture1.jpg recover
                exit

                BatFile2.bat
                Code: [Select]
                @echo off
                start /min BatFile1.bat
                start /wait paint.exe picture1.jpg
                move recover\picture1.jpg ..\automatic
                Download: Choice.exe

                raygra

                  Topic Starter


                  Rookie

                  Re: make [ Batch file to execute program ]
                  « Reply #8 on: January 30, 2009, 08:16:08 AM »

                  BatFile2.bat
                  Code: [Select]
                  @echo off
                  start /min BatFile1.bat
                  start /wait paint.exe picture1.jpg

                  I was getting an error, but after i removed  --- > picture1.jpg
                  It works ;) , thank you soo much for helping me out.


                  raygra

                    Topic Starter


                    Rookie

                    Re: make [ Batch file to execute program ]
                    « Reply #9 on: January 30, 2009, 11:26:04 AM »
                    is it possible to minimise cmd.exe window, and leave max window for paint.exe

                    because The script code: start /wait paint.exe
                    maximise both cmd.exe and paint.exe window.


                    macdad-



                      Expert

                      Thanked: 40
                      Re: make [ Batch file to execute program ]
                      « Reply #10 on: January 30, 2009, 12:22:33 PM »
                      i dont belive you can minimize progs that are currently running, but just add /MAX to your
                      Code: [Select]
                      Start Paint.EXE picture1.jpg
                      If you dont know DOS, you dont know Windows...

                      Thats why Bill Gates created the Windows NT Family.

                      raygra

                        Topic Starter


                        Rookie

                        Re: make [ Batch file to execute program ]
                        « Reply #11 on: January 30, 2009, 01:49:03 PM »
                        First, Thank you for your reply  :D I try      Max   and   Min 

                        start /wait/max paint.exe
                        maximise both       c:\window\system32\cmd.exe    and     paint.exe

                        start /wait/min paint.exe
                        open         c:\window\system32\cmd.exe    and   only minimise paint.exe

                        is there a way to position the c:\window\system32\cmd.exe window at top left of the screen
                        « Last Edit: January 30, 2009, 02:25:44 PM by raygra »

                        raygra

                          Topic Starter


                          Rookie

                          Re: make [ Batch file to execute program ]
                          « Reply #12 on: January 30, 2009, 03:10:54 PM »
                          YOu can minimise a running /wait  window(c:\window\system32\cmd.exe)


                          I have create an extra bat file in "Automatic " map/ folder.
                          Called: minimize.bat
                          ----------------------------
                          Batch Script code:
                          start /min minimize.bat

                          ----------------------------
                          It does work  :D


                          macdad-



                            Expert

                            Thanked: 40
                            Re: make [ Batch file to execute program ]
                            « Reply #13 on: January 30, 2009, 03:55:45 PM »
                            it doesn't for me, just starts a new window, but if it works for you then good.  ;)
                            atleast you have it going, but out of curiosity, whats this for?
                            If you dont know DOS, you dont know Windows...

                            Thats why Bill Gates created the Windows NT Family.

                            raygra

                              Topic Starter


                              Rookie

                              Re: make [ Batch file to execute program ]
                              « Reply #14 on: January 31, 2009, 06:39:13 AM »
                              Hi  :D

                              Because it cause an error after 2- 3 min. My backup is maybe currupt.

                              With my old backup no errors.

                              After, i create a new backup, i think it will run without errors. I use the batch tempolary.

                              Thanks you