# How to translate bash to .bat

**URL:** <https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 25, 2022, 1:01pm UTC](https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652 "2022-05-25T13:01:41Z")\
**Posts on this page:** 1\
**Showing post:** 26

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [May 26, 2022, 1:43am UTC](https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652/26 "2022-05-26T01:43:41Z")

</div>

### Registering a julia script file type/extension in Windows

Suggested here → [How to write a program as a Julia package? - #26 by MA\_Laforge](https://discourse.julialang.org/t/how-to-write-a-program-as-a-julia-package/80574/26)  
repo here → [GitHub - ma-laforge/JuliaScripting.jl](https://github.com/ma-laforge/JuliaScripting.jl)

In short, Windows allows you to register a file type, say `*.jl_script` to be executed with Julia in order to run. A sample file could be:

```julia-auto
#!JLScript -iq --startup-file=no --project=@SomeGlobalEnvironment
using ModuleFrom_SomeGlobalEnvironment

result = ModuleFrom_SomeGlobalEnvironment.run_important_tasks()
display(result)

:DONE

```

### Comments

- (Doesn’t actually need to use some global environment - but practical in terms of getting a stable Julia run environment)
- In the working example I provided, I pattern mach `#!JLScript` and pass the remaining arguments to the julia command.
- But if you want to be cross-compatible with how Linux shell scripts work, this could be changed to match some `#!/path/to/julia` pattern instead to match what @stevengj suggested to make julia scripts runnable on Unix/Linux.

### What already works

- Automatically loads the script using the desired, CLEAN, environment (starts with a clean `JULIA_LOAD_PATH` - see `install_files/launch_julia_script.ps1`.).
- Right now, my code \*auto-registers an “Excecute with Julia vX” Exprlorer menu item for the .jl\_script type (though I’m pretty certain I am using Win-XP Legacy registry settings).
- You can launch `.jl_script` files using RMB from explorer.

\*auto-registers: when you call `JuliaScripting.install()`

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/8/a8ba273da46ac397347c5aaa3ca675f4bdc8b4ad.png)

### What’s missing.

- Probably would be better to use newer methodology/registry settings if you are better at deciphering MS docs than I am.
- If you can figure out how to make this “Execute with Julia vX” item the default: then executing any `.jl_script` file from PowerShell or cmd will automatically run the script as intended.

Try it out for yourself: You can launch any `.txt` file from Windows PowerShell by typing in its the file name at the prompt. Doing so gets windows to figure out which “default program/action” to use to launch the `.txt` file.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-translate-bash-to-bat/81652)._
