Skip to content

sop/wslscript

Repository files navigation

Shell script (.sh) handler for Windows Subsystem for Linux (WSL).

Associates .sh (or any other) extension to be executed in WSL. Automatically handles Windows → Unix path conversions. Files can be dragged and dropped to registered file icon in explorer to pass paths as arguments.

Usage

Copy wslscript.exe and wslscript_handler.dll to a location of your choice. These files are used to invoke WSL, so don't move them afterwards.

Run wslscript.exe to open a setup GUI. Enter the extension and click Register button to add filetype association into Windows registry.

After registration, .sh files can be executed from explorer by double clicking. Other files can be passed as path arguments by dragging and dropping them into .sh file icon.

Scripts are executed in the same folder where the script file is located, ie. $PWD is set to script's directory.

Tips

Change the Default User

If scripts run as root, you may wish to change the default WSL user.

Add the following to /etc/wsl.conf file:

[user]
default = username

TODO

  • Optionally register for all users

License

This project is licensed under the MIT License.

Icon by Tango Desktop Project.