Windows 10: Start a program from a batch file

Discus and support Start a program from a batch file in Windows 10 Software and Apps to solve the problem; I'm trying to create a batch file that should - call another batch file - start a program and then wait for the program to close - call another... Discussion in 'Windows 10 Software and Apps' started by WebMaximus, Aug 18, 2015.

  1. Start a program from a batch file


    I'm trying to create a batch file that should

    - call another batch file
    - start a program and then wait for the program to close
    - call another batch file

    My goal with this is to work around an issue in Windows 10 where the screensaver won't work when I have my game controllers connected. I already created two batch files where one of them enables my game controllers and the other one disables them. Both these batch files work just fine.

    However I now want to create a third batch file that will do what listed above - first call the batch file that will enable my game controllers, then start my program which is an executable and then after I exited out of the program the batch file that will disable my game controllers should be called.

    Here's what I've tried but this doesn't work, it will only run the first batch file enabling my game controllers.

    Code: "c:\util\Game controllers - Enable.cmd" start "P:\Program Files (x86)\Lockheed Martin\Prepar3D v2\Prepar3D.exe" "c:\util\Game controllers - Disable.cmd"[/quote] Thanks in advance for any help.

    :)
     
    WebMaximus, Aug 18, 2015
    #1

  2. Start-up batch file

    I have a batch file that runs upon start-up. It has worked FINE from Win3 onwards, modified as necessary for each version of Windows. However, now I've got WinX, it doesn't work as it used to.

    Specifically, this line works just FINE:-

    Start "C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" "C:\Data\My WORD Documents\My File.docx"

    ... but NONE of these commands below does what I want it to, i.e. to load Excel and open a file, then get on with the Batch File:-

    1.

    "C:\Data\Excel\My File.xlsm"

    2.

    Start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Excel 2010.exe" "C:\Data\Excel\My File.xlsm"

    3.

    Start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Excel 2010.exe"

    4,

    Start "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe" "C:\Data\Excel\My File.xlsm"

    5.

    "C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe"

    No. 5 works, but a) it (obviously) doesn't load the file I want, and b) the Batch File then hangs.

    Help !
     
    Robin Clay, Aug 18, 2015
    #2
  3. kjl1956 Win User
    Check disk on a 1 bad sector but drive is 88% healthy, sshd 2 b mbr

    The results are as follows;

    U:\>

    U:\>Stage 1: Examining basic file system structure ...

    'Stage' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 1048064 file records processed.

    '1048064' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>File verification completed.

    'File' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 8622 large file records processed.

    '8622' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 0 bad file records processed.

    '0' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>Stage 2: Examining file name linkage ...

    'Stage' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 17170 reparse records processed.

    '17170' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 1155756 index entries processed.

    '1155756' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>Index verification completed.

    'Index' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 0 unindexed files scanned.

    '0' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 0 unindexed files recovered to lost and found.

    '0' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 17170 reparse records processed.

    '17170' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>Stage 3: Examining security descriptors ...

    'Stage' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>Security descriptor verification completed.

    'Security' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 53847 data files processed.

    '53847' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>CHKDSK is verifying Usn Journal...

    Invalid parameter - verifying

    U:\> 35872856 USN bytes processed.

    '35872856' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>Usn Journal verification completed.

    'Usn' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>Stage 4: Looking for bad clusters in user file data ...

    'Stage' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 1048048 files processed.

    '1048048' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>File data verification completed.

    'File' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>Stage 5: Looking for bad, free clusters ...

    'Stage' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 297247241 free clusters processed.

    '297247241' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>Free space verification is complete.

    'Free' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>Adding 1 bad clusters to the Bad Clusters File.

    'Adding' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>Windows has made corrections to the file system.

    'Windows' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>No further action is required.

    'No' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>1950916280 KB total disk space.

    '1950916280' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 760452004 KB in 448531 files.

    '760452004' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 263136 KB in 53848 indexes.

    '263136' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 4 KB in bad sectors.

    '4' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 1212176 KB in use by the system.

    '1212176' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 65536 KB occupied by the log file.

    '65536' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>1188988960 KB available on disk.

    '1188988960' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\> 4096 bytes in each allocation unit.

    '4096' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 487729070 total allocation units on disk.

    '487729070' is not recognized as an internal or external command,

    operable program or batch file.

    U:\> 297247240 allocation units available on disk.

    '297247240' is not recognized as an internal or external command,

    operable program or batch file.

    U:\>

    U:\>C:\WINDOWS\system32>
     
    kjl1956, Aug 18, 2015
    #3
  4. Start a program from a batch file

    The start command on line 2 treats your path in quotes as a window title only.
    Add the /d switch to declare the path first then call the executable.

    Code: start /d "P:\Program Files (x86)\Lockheed Martin\Prepar3d v2" Prepar3D.exe[/quote] reference: https://technet.microsoft.com/en-us/.../Cc770297.aspx
     
    LetsWindows10, Aug 19, 2015
    #4
  5. Many thanks!

    However your suggested command only works when I run it manually from the command line. Having it in a .cmd file double-clicking the .cmd file only executes the first line enabling the game controllers. I also tried creating a shortcut to the .cmd file and tick the 'Run as Administrator' option but still no go and same thing when right-clicking the .cmd file choosing 'Run as Administrator'.

    So...for whatever reason the command you suggested works perfectly fine when you run it manually from the command line but not when it's included in a .cmd file.

    Then there's the other question/problem how to make the .cmd file wait to execute the third line (disabling my game controllers) until Prepar3D.exe has quit.
     
    WebMaximus, Aug 20, 2015
    #5
  6. Try the following as your batch file:

    Code: start /b "" "c:\util\Game controllers - Enable.cmd" start /wait "" "P:\Program Files (x86)\Lockheed Martin\Prepar3D v2\Prepar3D.exe" start /b "" "c:\util\Game controllers - Disable.cmd"[/quote] Make sure the last line in your .cmd files is EXIT

    Prefaced 1st & 3rd line with start /b so that all 3 commands are called from the same parent and you can see them launch to confirm. The double quotes on each line are a kludge of sorts to get around the window title parameter and be able to use long filenames/paths.
     
    LetsWindows10, Aug 25, 2015
    #6
  7. Make sure the last line in your .cmd files is EXIT

    Prefaced 1st & 3rd line with start /b so that all 3 commands are called from the same parent and you can see them launch to confirm. The double quotes on each line are a kludge of sorts to get around the window title parameter and be able to use long filenames/paths.[/quote] Sorry for the late reply, have been building a new computer but now I'm finished and just tried what you suggest above and it works like a charm so many thanks *Smile !!

    This will be perfect until Microsoft hopefully addresses the issue where the screensaver in Win10 won't work with your game controllers connected and enabled.
     
    WebMaximus, Apr 5, 2018
    #7
Thema:

Start a program from a batch file

Loading...
  1. Start a program from a batch file - Similar Threads - Start program batch

  2. Starting batch file only opens command prompt versus running the batch file?

    in Windows 10 Software and Apps
    Starting batch file only opens command prompt versus running the batch file?: I'm trying to run one batch file, then another. Instead of running the 2nd batch file, it just opens another black screened command prompt with the name of the batch file as the first line in the command prompt? Any ideas why?...
  3. Starting two programs from a single batch file is different than starting two programs in...

    in Windows 10 Ask Insider
    Starting two programs from a single batch file is different than starting two programs in...: First Concrete example: I run “Start Resident Evil 2” from a batch file I run “Start Resident Evil 2 Trainer” from another batch file Everything works! Okie dokie... So let’s simplify it a bit... I run “Start Resident Evil 2” and “Start Resident Evil 2 Trainer” from the...
  4. Restart a specific program with a batch file

    in Windows 10 Ask Insider
    Restart a specific program with a batch file: I have to restart Windows Audio Device graph multiple times a day to the point that I just want to map a button on my stream deck to end the task. Is there a way to create a shortcut to end the task? I've tried taskkill /f /im audiodg.exe but that was unsuccessful. Any ideas?...
  5. Batch Scripts / Programs.

    in Windows 10 Performance & Maintenance
    Batch Scripts / Programs.: The members and quests who use this forum know how professional, informative and helpful it is! In order to help members solve their problems/issues we often ask them to run certain programs and perform certain tasks and then upload [ post ] the results to the forum for us...
  6. Batch File in start up

    in Windows 10 Network and Sharing
    Batch File in start up: I have created a batch file for cleaning up all temporary and unnecessary file which can be run any time. I want to add this file with the startup of windows 10, so that when ever I start the windows, the file will automatically run and clean up my PC. In windows 7, you can...
  7. Looking for a program to batch resize .png files.

    in Windows 10 Software and Apps
    Looking for a program to batch resize .png files.: I use Photoshop for .jpg files, but it can't seem to do .png. What programs can do this? 57086
  8. Start a program from a batch file

    in Windows 10 Software and Apps
    Start a program from a batch file: 4 Apps of mine run a batch file that -tries- to call/start and EXE program. These Batch files need to work with OS XP thru Win 10. Win 10 has a pop-up window asking user if its okay to run/execute my EXE. No other Win version does this and thus I suspect a timing problem....
  9. Batch file start program minimized

    in Windows 10 Support
    Batch file start program minimized: Here's a little script to make a backup of 2 directories: Code: ::can't copy Opera data while Opera is running taskkill /im opera.exe robocopy c:\all e:\Bobback\All /mir robocopy c:\Users\Bob\AppData\Roaming e:\Bobback\Roaming /mir ::restart Opera minimized start...
  10. Batch file - Unable to start a program minimized

    in Windows 10 Support
    Batch file - Unable to start a program minimized: I've been trying to figure this out for a while now and I can't. I've looked at tons of small tips online to get this working but it doesn't work at all. I have a batch file which causes various programs to start when opened. However, one of them always appears above the rest...

Users found this page by searching for:

  1. batch file for app allocation prepar3d