What happened to my Windows (.bat) file?

I created a simple batch file (.bat) containing a bunch of commands that should run automatically in a command window. The package looks like this:

mmd dll1.dll -mf -aW
mmd dll2.dll -mf -aW
mmd dll3.dll -mf -aW

      

If I copy and paste a bunch of cmds into the command window, they all execute correctly. However, if I try to directly drag and drop the batch file into the command window and execute it, the first command runs and does not succeed. Why?

In the command window where I run the commands, many environment variables need to be set before the commands can run successfully. When I drag and drop the batch file (with an absolute path) it looks like I have never set these variables. Are commands from a batch file being executed in the same context using the hosting command prompt window? How should I do it?

0


source to share


5 answers


Executing a dragged file with the path to the .bat file (and not where those DLLs actually are)?



+1


source


Perhaps you have special characters in your commands that affect batch files, like%. You will need to remove / delete them.



If not, it probably has to do with the program you are running, either messing with the terminal, or being very dependent on your environment. Do you have information about this? Try to run only the first line in the batch file.

+1


source


Are you trying to add "call" before commands in ".bat"?

By adding a "call" before your cmd line, you ensure that the parent process continues when the child process ends.

+1


source


Do you put quotes around the filenames you are calling? And the file names are on different lines? (If not, they should be)

0


source


Is the PATH set correctly? Are you in the correct directory when executing the package? Have you checked for invisible invalid characters in the batch file?

0


source







All Articles