.BAT/Batch file, how can I open it?

Hi! I have a few .bat files that I have and also have made on Windows to do some things useful and I can’t find anywhere on how to run these on Manjaro. I’ll provide any information you need.
I’m using Manjaro XFCE.

.bat files contain Windows-specific commands.

Either you can try your luck with wine or a virtual machine (running a Windows guest), or dual-boot into Windows.

Regardless, the BAT script might contain commands that require executables that are not available/installed by default under Wine.

2 Likes

As @ winnie said .bat files are script files for MS Windows ONLY.

If you want to do things with scripts on ANY Linux OS, including Manjarao, you will need to create bash shell scripts, they look like this…

#!/bin/bash

ls -al

for example.

They are usually saved as filename.sh though the file extension isn’t necessary except to document to you the user what sort of file it is.

they are made executable with the following command…

chmod +x filename.sh
2 Likes

You might find “Learning the Shell” and “Writing Shell Scripts” helpful.

If you type help on the command line, you’ll get a bash cheatsheet. You can get further information by typing help <word_from_cheatsheat> or man bash. The bash reference can be viewed online. And a great unofficial resource is this BashFAQ.

Most of the basic/core utilities come from gnu.org.

The executable shell script can be executed 3 ways:

  1. Relative path. You are in the directory structure where the script resides.
    • ./script
  2. Absolute path. You provide the full path to the script.
    • /home/USER/source/bash/script
  3. The script resides in your system’s search path.
    • script
      To see the directories in the path type echo $PATH
      For a regular user the directory that is in the path these days is ~/.local/bin.
2 Likes

You can “open” it with a text editor. Right click on the file, and select Open With and then your editor. This will allow you to see the commands that it will try and execute and edit the file, as if it were any other text file. From there you can translate the commands into a script file. Good luck.

1 Like

Thank you! Although I’ll try a VM, I’ll also try this. Thank you all for your recommendations!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.