Windows Terminal Command Line Scripting

n8chavez

Level 24
Thread author
Well-known
Feb 26, 2021
1,346
2
3,647
2,268
42
I used to be able to run windows command line scripts just double clicking the bat file, but now I can't I'm and not sure why. When I try to execute scripts that used to work, the terminal opens but nothing happens. I can copy the script in the bat file and paste into a terminal and everything runs just fine. It's just that the script doesn't execute via .bat file anymore. Anyone have any ideas why?
 
It sounds like the file association for .bat files might have changed. Try resetting it to cmd.exe. You can do this by going to Settings > Apps > Default Apps > Choose default applications by file type. Find .bat and set it to cmd.exe. If it's already set to cmd.exe, try changing it to something else, then change it back to cmd.exe. This might reset any issues causing the problem.
 
Choosing the default app by .bat file doesn't seem to be an option. When I tried there was no listing.
 
Try Start > Windows Tools > Command Prompt and run your bat files inside that command window. Just to make sure that this way still works.
 
  • Like
Reactions: n8chavez
That way works just fine; if I run, for example "c:\scripts\test.bat" in that cl window. It's just that I cannot schedule or automate my scripts now.
 
Since you mentioned that the scripts work fine when copied into a terminal, it seems like the problem is specifically with executing the .bat files. A few things you might want to check:
File Associations: Make sure .bat files are still associated with the Command Prompt. You can check this in the default apps settings.
Permissions: Ensure that the .bat files have the necessary permissions to execute. Right-click on the file, go to Properties, and check the Security tab.
 
Since you mentioned that the scripts work fine when copied into a terminal, it seems like the problem is specifically with executing the .bat files. A few things you might want to check:
File Associations: Make sure .bat files are still associated with the Command Prompt. You can check this in the default apps settings.
Permissions: Ensure that the .bat files have the necessary permissions to execute. Right-click on the file, go to Properties, and check the Security tab.

Than you for the help. But, as I mentioned above (here), I solved it already.