-4

I want to write a batch file that will open all files in D:\software.

I have searched the internet but could not find anything. Can anyone help me?

Chris
  • 7,270
  • 19
  • 66
  • 110
  • 1
    You're not going to just *find* a script like that, you need to *write* one. Just iterate through the directory with a `FOR` loop, then run each program. I sure hope there aren't a lot of programs in that directory, though... – LittleBobbyTables - Au Revoir Jan 21 '15 at 18:56
  • 1
    Welcome to Stack Overflow! You should be able to find a number of resources by searching on this site: http://stackoverflow.com/questions/5909012/windows-batch-script-launch-program-and-exit-console, http://stackoverflow.com/questions/39615/how-to-loop-through-files-matching-wildcard-in-batch-file – Nate Barbettini Jan 21 '15 at 19:02
  • 1
    Welcome! Here is a quick search with relevant results. https://www.google.com/#q=dos+open+all+files+in+a+folder – user4317867 Jan 22 '15 at 05:45

1 Answers1

0

Here's a batch script that will navigate to D:\software and execute all programs (*.exe):

executeAll.cmd

cd D:\software
for %%f in (*.exe) do (
    echo %%~nf
    start "" "%%f"
)
exit

If you want the script to open all files, change the first line to

for %%f in (*.*) do (

In order to run the batch file, you'll need to save it with the proper extension. In Notepad, this is trivial but not obvious: when you save the file, put quotes around the filename + extension, like "executeAll.cmd". Otherwise, it will be saved with a .txt extension like executeAll.cmd.txt.

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
  • thats not working :( when i use the .exe line he will open widows vieuwer – Martijn ter Arkel Jan 21 '15 at 19:28
  • im using windows 8.1 or is that the problem? – Martijn ter Arkel Jan 21 '15 at 19:32
  • I'm using Windows 8.1 too so that's not it. Did you save the batch file with the correct extension? I updated my answer with instructions. – Nate Barbettini Jan 21 '15 at 19:51
  • @MartijnterArkel - It almost sounds like you have .exe files associated with Windows Viewer. – SomethingDark Jan 22 '15 at 05:22
  • If you used the `*.*` the script will open every file wih the default associated program. For example `.TXT` opens with `Notepad.exe` unless you make the script open the file(s) with another program. For example: `C:\Apps\Notepad++.EXE myfile.txt` will open the Text file in Notepad++. – user4317867 Jan 22 '15 at 06:14