├── .gitignore ├── LICENSE ├── RunBash.bat ├── RunBash.c ├── RunBash.manifest ├── RunBash.rc ├── images ├── ContextMenu.png ├── RunBash in Action (1).png ├── RunBash in Action (2).png ├── RunBash in Action (3).png ├── bash.ico └── root.ico ├── readme.md └── setup.bat /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | test/ 3 | data/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Benzaria 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RunBash.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | chcp 65001 >nul 4 | 5 | ::╔═══════════════════════════════════════════════════════════════════════╗:: 6 | ::║ RunBash MadeBy Benzaria ║:: 7 | ::║ Run Bash Scripts and Binaries Directly from Windows ║:: 8 | ::║ Via Windows Explorer And Command Prompt ║:: 9 | ::╚═══════════════════════════════════════════════════════════════════════╝:: 10 | :: ver 1.3 >> for more info check https://github.com/benzaria/RunBash :: 11 | 12 | :: Default Parameters 13 | set "Std=3" & rem Display Standard Output And Error 14 | set "Exit=3" & rem Display ExitCode And Success Msg 15 | set "NoWait=" & rem Wait For The Execution 16 | 17 | if /i "%~x1" equ ".exe" ( 18 | set /a n = 1 19 | shift /0 20 | ) 21 | 22 | :: Capturing Arguments 23 | if "%~1" equ "" ( 24 | echo Usage: %~n0 [Arguments] ^ 25 | echo ^>^> for more info : %~n0 -help 26 | exit /b 1 27 | ) else ( 28 | if /i "%~1" equ "-Help" goto :_Help_ 29 | if /i "%~1" equ "-Install" goto :_Install_ 30 | set "arg_=" && set "arg=%*" && set "arg=!arg:;=¬!" 31 | for %%i in (!arg!) do ( 32 | if !n! leq 0 ( 33 | set "arg=%%~i" 34 | call :!arg! 2>nul 35 | if !ErrorLevel! neq 0 ( 36 | if defined next ( 37 | set "!next!=!arg!" 38 | set "next=" 39 | ) else set "arg_=!arg_!%%i " 40 | ) 41 | ) else set /a n -= 1 42 | ) 43 | ) 44 | 45 | :: Paths And Arguments Handling 46 | set "arg=" 47 | for %%i in (!arg_!) do ( 48 | if exist "%%~i" ( 49 | for /f "delims=" %%j in (' wsl --cd "%%~dpi" pwd ') do ( 50 | set "filepath=%%~j/%%~nxi" 51 | set "arg=!arg!"!filepath!" " 52 | ) 53 | ) else set "arg=!arg!%%i " 54 | ) 55 | 56 | if defined Bin goto :!Bin! 57 | 58 | :: Show Arguments Passed (!Gets Passed When Piping!) 59 | rem echo /bin/bash !arg! 60 | 61 | :: Output Handling 62 | if !Std! equ 0 ( set "style=1>nul 2>&1" ) 63 | if !Std! equ 1 ( set "style=2>nul" ) 64 | if !Std! equ 2 ( set "style=1>nul" ) 65 | 66 | :: Execute The File 67 | if defined NoWait ( 68 | start /b "" PowerShell -NoProfile -Command "Start-Process -WindowStyle Hidden wsl.exe -ArgumentList '!root! !arg! !style!'" 69 | ) else wsl !root! !arg! !style! 70 | 71 | echo. 72 | 73 | :: Print Exit Msg 74 | if !Exit! neq 0 ( 75 | :: remove '' to make a new line after the exit msg 76 | if !ErrorLevel! neq 0 ( 77 | if !Exit! neq 2 ( 78 | echo Exited With ErrorCode=!ErrorLevel! 79 | ) 80 | ) else if !Exit! neq 1 ( 81 | echo Exited With No Errors. 82 | ) 83 | ) 84 | 85 | :: Keeping Wsl Awake For 1h For Faster Execution 86 | for /f "tokens=2" %%i in (' tasklist /fi "imagename eq wsl.exe" /nh ') do ( 87 | if /i "%%~i" equ "No" ( 88 | start /b "" PowerShell -NoProfile -Command "Start-Process -WindowStyle Hidden wsl.exe -ArgumentList 'sleep 1h && exit'" 89 | ) 90 | ) 91 | 92 | endlocal 93 | EXIT /B %ErrorLevel% 94 | 95 | :: Select Case 96 | :-Root 97 | set "Root=-u root" 98 | exit /b 0 99 | :-NoWait 100 | set "NoWait=True" 101 | exit /b 0 102 | :-Std 103 | :-Exit 104 | set "next=!arg:-=!" 105 | exit /b 0 106 | :-GetBin 107 | :-AddBin 108 | :-RemBin 109 | set "bin_dir=%ProgramData%\RunBash\Linux-Binary\" 110 | set "Bin=_!arg:-=!_" 111 | exit /b 0 112 | :: End Select 113 | 114 | :_EnvVar_ 115 | :: Adding The Directory To The PATH EnvVar 116 | echo %PATH% | find /i "%~dp1" >nul || PowerShell -NoProfile -Command "Start-Process -Wait -WindowStyle Hidden -Verb RunAs PowerShell -ArgumentList '-NoProfile', '-Command', \"[System.Environment]::SetEnvironmentVariable('Path', [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) + ';%~dp1', [System.EnvironmentVariableTarget]::Machine)\"" 2>nul && echo Make sure to restart Cmd After finishing || echo Error: Elevated Privileges not Granted. && exit /b 1 117 | if "%~2" neq "" echo %PATHEXT% | find /i "%~2" >nul || PowerShell -NoProfile -Command "Start-Process -Wait -WindowStyle Hidden -Verb RunAs PowerShell -ArgumentList '-NoProfile', '-Command', \"[System.Environment]::SetEnvironmentVariable('PATHEXT', [System.Environment]::GetEnvironmentVariable('PATHEXT', [System.EnvironmentVariableTarget]::Machine) + ';%~2', [System.EnvironmentVariableTarget]::Machine)\"" 2>nul || exit /b 1 118 | exit /b 0 119 | 120 | :_GetBin_ 121 | mkdir "!bin_dir!" 2>nul 122 | call :_EnvVar_ !bin_dir! || exit /b 1 123 | :: Collecting All Possible Executable Files 124 | for /f "delims=" %%i in (' wsl find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin /home !arg! -type l -o -type f -executable -o \^( -type f \^( -name "*.sh" -o -name "*.bash" -o -name "*.py" \^) \^) -o -path /mnt/c -prune ') do ( 125 | :: Filtering NON Executable Files 126 | for %%a in ("" ".sh" ".bash" ".py") do ( 127 | if /i "%%~xi" equ "%%~a" ( 128 | if not exist "!bin_dir!%%~ni.bat" ( 129 | set /a n += 1 130 | echo Adding %%~i 131 | echo @RunBash "%%~i" %%* > "!bin_dir!%%~ni.cmd" 132 | ) 133 | ) 134 | ) 135 | ) 136 | echo !n! Links Has Been Added. 137 | exit /b 0 138 | 139 | :_AddBin_ 140 | for /f "tokens=1* delims=¬" %%i in ("!arg!") do ( 141 | for /f "tokens=1*" %%a in ("%%~i") do ( 142 | echo %%~a -^> %%~b 143 | echo @RunBash %%~b %%* > "!bin_dir!%%~a.bat" 144 | del "!bin_dir!%%~a.cmd" 2>nul 145 | ) 146 | set "arg=%%j" 147 | ) 148 | if defined arg goto :_AddBin_ 149 | exit /b 0 150 | 151 | :_RemBin_ 152 | if not defined arg ( 153 | choice /n /m "Are You Sure, Delete All Links (yes|no)" 154 | if !ErrorLevel! equ 1 ( 155 | del /q "!bin_dir!" 156 | echo All Links has been Deleted. 157 | ) 158 | ) 159 | for %%i in (!arg!) do del "!bin_dir!%%~i.*" 160 | exit /b 0 161 | 162 | :_Install_ 163 | net session >nul 2>&1 164 | if !ErrorLevel! neq 0 ( 165 | PowerShell -NoProfile -Command "Start-Process -Wait -WindowStyle Hidden -Verb RunAs \"%~0\" -ArgumentList '-Install \"%~2\" \"%~3\"'" 2>nul || echo Error: Elevated Privileges not Granted. 166 | exit /b 1 167 | ) 168 | 169 | if not exist "%temp%\msgbox" ( 170 | mshta vbscript:Execute^("if msgbox(""Overwrite RunBash.bat if Existed ?"", vbYesNo + vbQuestion + vbSystemModal,""RunBash Installer"") = vbyes then CreateObject(""Scripting.FileSystemObject"").CreateTextFile ""%temp%\msgbox"", true end if"^)^(window.close^) 171 | if exist "%temp%\msgbox" ( 172 | move /y "%ProgramData%\RunBash\RunBash.bat" "%ProgramData%\RunBash\RunBash.old" >nul 2>&1 173 | start /b /wait "" "%~f0" -Install "%~2" "%~3" 174 | exit /b 0 175 | ) 176 | ) else del "%temp%\msgbox" 177 | 178 | set "istl_dir=%windir%\RunBash.exe" 179 | set "edit_dir=%windir%\notepad.exe" 180 | if "%~2" neq "" if "%~2" neq " " set "istl_dir=%~2" 181 | if "%~3" neq "" set "edit_dir=%~3" 182 | 183 | copy /y "%~0" "!istl_dir!" || mshta vbscript:msgbox("Error: Installing Failed, Install Path is Incorrect!",vbExclamation,"RunBash Installer")(window.close) && exit /b 1 184 | call :_EnvVar_ !istl_dir! ".SH" 185 | 186 | reg add "HKEY_CLASSES_ROOT\bashfile" /ve /d "Linux Bash File" /f 187 | reg add "HKEY_CLASSES_ROOT\bashfile\DefaultIcon" /ve /d "!istl_dir!,0" /f 188 | 189 | reg add "HKEY_CLASSES_ROOT\bashfile\shell" /f 190 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\open" /v Icon /d "!istl_dir!,0" /f 191 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\open\command" /ve /d "\"!istl_dir!\" \"%%1\" %%*" /f 192 | 193 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\1open" /ve /d "Run as Root" /f 194 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\1open" /v Icon /d "!istl_dir!,1" /f 195 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\1open\command" /ve /d "\"!istl_dir!\" -root \"%%1\" %%*" /f 196 | 197 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\runas" /ve /d "Run as Admin" /f 198 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\runas" /v HasLUAShield /d "" /f 199 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\runas\command" /ve /d "\"!istl_dir!\" \"%%1\" %%*" /f 200 | 201 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\xedit" /ve /d "Edit" /f 202 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\xedit" /v Icon /d "\"!edit_dir!\"" /f 203 | reg add "HKEY_CLASSES_ROOT\bashfile\shell\xedit\command" /ve /d "\"!edit_dir!\" \"%%1\"" /f 204 | 205 | reg add "HKEY_CLASSES_ROOT\.sh" /ve /d "bashfile" /f 206 | reg add "HKEY_CLASSES_ROOT\.bash" /ve /d "bashfile" /f 207 | reg add "HKEY_CLASSES_ROOT\.bashrc" /ve /d "bashfile" /f 208 | 209 | reg add "HKEY_CLASSES_ROOT\.sh\ShellNew" /ve /f 210 | reg add "HKEY_CLASSES_ROOT\.sh\ShellNew" /v NullFile /d "" /f 211 | 212 | if !ErrorLevel! equ 0 ( 213 | mshta vbscript:msgbox^("Registry entries have been added successfully.",vbInformation,"RunBash Installer"^)^(window.close^) 214 | taskkill /f /im explorer.exe 215 | start explorer.exe 216 | ) else mshta vbscript:msgbox^("Error: Registry entries haven't been added.",vbCritical,"RunBash Installer"^)^(window.close^) 217 | exit /b 0 218 | 219 | :_Help_ 220 | echo  221 | echo ╔═══════════════════════════════════════════════════════════════════════╗ 222 | echo ║ RunBash MadeBy Benzaria ║ 223 | echo ║ Run Bash Scripts and Binaries Directly from Windows ║ 224 | echo ║ Via Windows Explorer And Command Prompt ║ 225 | echo ╚═══════════════════════════════════════════════════════════════════════╝ 226 | echo ver 1.3 ^>^> for more info check https://github.com/benzaria/RunBash 227 | echo  228 | echo %~n0 [Wsl-Arguments] [RunBash-Arguments] ^ [File-Arguments] 229 | echo or 230 | echo ^ [File-Arguments] [RunBash-Arguments] 231 | echo  232 | echo [Wsl-Arguments] for info ^>^> Wsl --help 233 | echo  234 | echo [RunBash-Arguments] 235 | echo  236 | echo -GetBin ^ Gather all Executable files from the Linux Distribution 237 | echo And Link them to the Windows Path EnvVar. default dirs : 238 | echo (/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin /home) 239 | echo  240 | echo -RemBin ^ Remove Added Commands To Windows, if no name specified 241 | echo All Links will be Removed After a Confirmation message 242 | echo (%~n0 -RemBin ls sudo find grep apt gcc py vim ...) 243 | echo  244 | echo -AddBin ^ ^ ; ^ ^ ; ... 245 | echo Add Custom Commands with parameters from Linux To Windows 246 | echo (%~n0 -AddBin ll ls --color=auto -l ; la ls -a ; ...) 247 | echo  248 | echo -Install ^ ^ 249 | echo Install ContextMenu and RunBash Plugins to Explorer and Cmd 250 | echo To skip the install-path type ` -Install " " "editor-path" ` 251 | echo (default : "%windir%\notepad.exe" "%windir%\RunBash.exe") 252 | echo  253 | echo -NoWait  Don't Wait For The Execution to Finish 254 | echo  255 | echo -Root  Run File With Root User Privileges 256 | echo  257 | echo -Std ^<0-2^> 0: Don't Display any Output 258 | echo 1: Display only Standard Output 259 | echo 2: Display only Standard Error 260 | echo  261 | echo -Exit ^<0-2^> 0: Don't Display a thing on Exit 262 | echo 1: Display The ErrorCode on Exit 263 | echo 2: Display A Success Msg on Exit 264 | echo  265 | echo | set /p="[] ^!^! Wsl is needed for The program to run properly ^!^!" 266 | echo  267 | echo  268 | echo ^> The RunBash Source Code is Located at \ProgramData\RunBash\RunBash.bat 269 | echo Be Aware That Modifying The Source Code Effects The RunBash Execution 270 | exit /b 0 271 | -------------------------------------------------------------------------------- /RunBash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | //╔═══════════════════════════════════════════════════════════════════════╗// 6 | //║ RunBash MadeBy Benzaria ║// 7 | //║ Run Bash Scripts and Binaries Directly from Windows ║// 8 | //║ Via Windows Explorer And Command Prompt ║// 9 | //╚═══════════════════════════════════════════════════════════════════════╝// 10 | // ver 1.3 >> for more info check https://github.com/benzaria/RunBash // 11 | 12 | // Check if a file exists 13 | int file_exists(const char *path) { 14 | DWORD attrib = GetFileAttributes(path); 15 | return (attrib != INVALID_FILE_ATTRIBUTES && !(attrib & FILE_ATTRIBUTE_DIRECTORY)); 16 | } 17 | 18 | // Check if a directory exists, else create it 19 | void dir_exists(const char *dir_path) { 20 | DWORD attrib = GetFileAttributes(dir_path); 21 | 22 | if (attrib == INVALID_FILE_ATTRIBUTES || !(attrib & FILE_ATTRIBUTE_DIRECTORY)) { 23 | if (!CreateDirectory(dir_path, NULL)) { 24 | printf("Error: Could not Create RunBash directory %s.\n", dir_path); 25 | exit(1); 26 | } 27 | } 28 | } 29 | 30 | // Extract the embedded RunBash and save it to disk 31 | void extract_RunBash(const char *file_path) { 32 | HRSRC hRes = FindResource(NULL, "RunBash", RT_RCDATA); 33 | HGLOBAL hResData = LoadResource(NULL, hRes); 34 | DWORD resSize = SizeofResource(NULL, hRes); 35 | void *pResData = LockResource(hResData); 36 | 37 | if (hRes == NULL || hResData == NULL || pResData == NULL) { 38 | printf("Error: Could not Extract RunBash resource.\n"); 39 | return; 40 | } 41 | 42 | FILE *outputFile = fopen(file_path, "wb"); 43 | if (outputFile == NULL) { 44 | printf("Error: Could not Create RunBash file %s.\n", file_path); 45 | return; 46 | } 47 | fwrite(pResData, 1, resSize, outputFile); 48 | fclose(outputFile); 49 | } 50 | 51 | // Handle special characters in arguments 52 | void handle_argument(char *dest, const char *src) { 53 | if (strpbrk(src, " =\",")) { 54 | strcat(dest, "\""); 55 | strcat(dest, src); 56 | strcat(dest, "\""); 57 | } else { 58 | strcat(dest, src); 59 | } 60 | } 61 | 62 | // Run RunBash with arguments 63 | void RunBash(const char *file_path, int argc, char *argv[]) { 64 | char command[4096] = {0}; 65 | snprintf(command, sizeof(command), "cmd /c \"\"%s\"", file_path); 66 | 67 | for (int i = 0; i < argc; i++) { 68 | strcat(command, " "); 69 | handle_argument(command, argv[i]); 70 | } 71 | 72 | strcat(command, "\""); 73 | system(command); 74 | } 75 | 76 | // Get the full path based on %ProgramData% 77 | void get_full_path(char *full_dir_path, const char *subdir, char *full_file_path, const char *filename, char *full_exe_path) { 78 | char programData[MAX_PATH]; 79 | GetModuleFileName(NULL, full_exe_path, MAX_PATH); 80 | GetEnvironmentVariable("ProgramData", programData, MAX_PATH); 81 | 82 | snprintf(full_dir_path, MAX_PATH, "%s\\%s", programData, subdir); 83 | snprintf(full_file_path, MAX_PATH, "%s\\%s", full_dir_path, filename); 84 | } 85 | 86 | // Get the full path of the executable 87 | void get_exe_path(char *full_path, int size) { 88 | if (!GetModuleFileName(NULL, full_path, size)) { 89 | printf("Error: Could not get the full path of the executable.\n"); 90 | exit(1); 91 | } 92 | } 93 | 94 | int main(int argc, char *argv[]) { 95 | char exe_path[MAX_PATH]; 96 | char dir_path[MAX_PATH]; 97 | char file_path[MAX_PATH]; 98 | 99 | // Get the directory, file and exe paths 100 | get_full_path(dir_path, "RunBash", file_path, "RunBash.bat", exe_path); 101 | 102 | // Check if the RunBash already exists 103 | if (!file_exists(file_path)) { 104 | dir_exists(dir_path); 105 | extract_RunBash(file_path); 106 | } 107 | 108 | argv[0] = exe_path; 109 | RunBash(file_path, argc, argv); 110 | 111 | return 0; 112 | } 113 | -------------------------------------------------------------------------------- /RunBash.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Run Bash Scripts and Binaries Directly from Windows 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /RunBash.rc: -------------------------------------------------------------------------------- 1 | RunBash RCDATA "RunBash.bat" 2 | BASH ICON "bash.ico" 3 | ROOT ICON "root.ico" 4 | 1 24 "RunBash.manifest" 5 | 1 VERSIONINFO 6 | FILEVERSION 1,3,0,0 7 | PRODUCTVERSION 1,3,0,0 8 | FILEOS 0x4 9 | FILETYPE 0x1 10 | { 11 | BLOCK "StringFileInfo" 12 | { 13 | BLOCK "040904B0" 14 | { 15 | VALUE "CompanyName", "benzaria" 16 | VALUE "FileDescription", "Run Bash Scripts and Binaries Directly from Windows" 17 | VALUE "FileVersion", "1.3" 18 | VALUE "InternalName", "RunBash.exe" 19 | VALUE "LegalCopyright", "\xA9 benzaria" 20 | VALUE "OriginalFilename", "RunBash.exe" 21 | VALUE "ProductName", "RunBash 32-bit" 22 | VALUE "ProductVersion", "1.3" 23 | } 24 | } 25 | BLOCK "VarFileInfo" 26 | { 27 | VALUE "Translation", 0x0409, 1200 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /images/ContextMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/ContextMenu.png -------------------------------------------------------------------------------- /images/RunBash in Action (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/RunBash in Action (1).png -------------------------------------------------------------------------------- /images/RunBash in Action (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/RunBash in Action (2).png -------------------------------------------------------------------------------- /images/RunBash in Action (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/RunBash in Action (3).png -------------------------------------------------------------------------------- /images/bash.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/bash.ico -------------------------------------------------------------------------------- /images/root.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benzaria/RunBash/b12cba9da2482f787aa945de6a03d519500cb944/images/root.ico -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # RunBash by Benzaria 2 | ![](https://img.shields.io/badge/Windows-blue) ![](https://img.shields.io/badge/Linux-white?logo=linux&logoColor=black) ![](https://img.shields.io/badge/Batch-blue) ![](https://img.shields.io/badge/Bash-white?logo=gnubash&logoColor=black) ![](https://img.shields.io/badge/-blue?logo=c&logoColor=white) ![](https://img.shields.io/github/repo-size/benzaria/runbash) ![](https://img.shields.io/badge/RunBash_size-300KB-green) 3 | 4 | ## Overview 5 | 6 | 7 | **RunBash** is a handful utility that enables you to run your Bash Scripts and Linux Binarys directly from your Windows system, seamlessly integrating Linux commands into your Windows environment. Whether through Windows Explorer, Command Prompt, and PowerShell, RunBash offers a versatile and efficient way to execute Bash scripts and Binarys without the need for a separate terminal. 8 | 9 | ## Table of Contents 10 | - [Features](#features) 11 | - [Getting Started](#getting-started) 12 | - [Installation](#installation) 13 | - [Usage](#usage) 14 | - [Arguments](#arguments) 15 | - [Details](#details) 16 | 17 | 18 | ## Features 19 | - **Direct Seamless Execution:** Run Bash scripts and Linux binarys from Windows Explorer or the Command Prompt with ease. 20 | - **Linux Command Integration:** Easily link and manage Linux commands within your Windows environment. 21 | - **Context Menu Plugins:** Add Multiple Option to the context menu from: Open, Run as Root, Run as Admin, Edit, and New Bash File. [Details](#details) 22 | - **Customizable SourceCode:** add Any code you want to the main batchfile (\ProgramData\RunBash\RunBash.bat) to adjust the execution into your needs. 23 | - **Customizable Execution:** Use various parameters to control output, error handling, and execution behavior. 24 | - **Root/Admin Access:** Optionally run scripts with Root or Admin privileges. 25 | - **Error and Output Handling:** Fine-tune what outputs and errors are displayed or hidden. 26 | > [!NOTE] 27 | > The Batchfile Can Not Run on it's Own it needs the main exe ahead of it 28 | 29 | ## Getting Started 30 | ### Prerequisites 31 | - **WSL (Windows Subsystem for Linux)** is required for RunBash to function. Please ensure that WSL is installed on your system. 32 | - Quick install : `wsl --install && shutdown /r` optional : `wsl --set-default-version 2` if supported ! 33 | 34 | ### Installation 35 |  1. Clone the Repository `Git Clone https://github.com/benzaria/RunBash.git` 36 | or 37 |  2. Download the Latest Release [RunBash v1.3](https://github.com/benzaria/RunBash/archive/refs/tags/1.3.zip). 38 | 39 | ### Usage 40 | RunBash can be invoked directly from the Command Prompt. Here are the basic usage instructions: 41 | 42 | First run `setup.bat` it will do all the work to make sure RunBash is setup perfectly. 43 | \- else run `RunBash -Install & RunBash -GetBin` for Basic setup ! 44 | 45 | ``` 46 | Usage: 47 | RunBash [Wsl-Arguments] [RunBash-Arguments] [File-Arguments] 48 | or after setting up 49 | [File-Arguments] [RunBash-Arguments] 50 | ``` 51 | 52 | #### Example: 53 | ``` 54 | RunBash -Std 1 -Exit 1 -Root C:\Users\benz\sleepsort.sh 55 | or after setting up 56 | C:\Users\benz\sleepsort.sh -Std 1 -Exit 1 -Root 57 | ``` 58 | 59 | ### Arguments 60 | - **[Wsl-Arguments]:** Standard arguments passed to WSL. For more info, run `wsl --help`. 61 | - **[RunBash-Arguments]:** 62 | - `-Install `: Install ContextMenu and RunBash Plugins to Explorer and Cmd. [Details](#details) 63 | - `-GetBin `: Gather all executable files from specified Linux directories and link them to Windows. 64 | - `-AddBin ; ;...`: Add custom commands from Linux to Windows. 65 | - `-RemBin `: Remove specified or all linked commands from Windows. 66 | - `-NoWait`: Do not wait for script execution to finish. 67 | - `-Root`: Run the script as the root user. 68 | - `-Std <0-2>`: Control output display: 69 | - `0`: No output 70 | - `1`: Display Standard output only 71 | - `2`: Display Standard error only 72 | - `-Exit <0-2>`: Control exit message display: 73 | - `0`: No exit message 74 | - `1`: Display error code on exit 75 | - `2`: Display success message on exit 76 | 77 | #### Help 78 | For a detailed guide on using RunBash, run: `RunBash -Help` 79 | 80 | ### Details 81 | ![Explorer/Context Menu](/images/ContextMenu.png) 82 | ![RunBash in Action](/images/RunBash%20in%20Action%20(1).png) 83 | ![RunBash in Action](/images/RunBash%20in%20Action%20(2).png) 84 | > [!IMPORTANT] 85 | > Make sure to run either the commands `runbash -addbin ` or `runbash -getbin` after installing a new package 86 | > :bulb: Coming soon : Automatic Link after a new package install 87 | 88 | ![RunBash in Action](/images/RunBash%20in%20Action%20(3).png) 89 | 90 | ## LICENSE 91 | RunBash is licensed under the [MIT License](/LICENSE) 92 | 93 | ## Contribution 94 | Feel free to contribute by submitting issues or pull requests. Any enhancements or bug fixes are welcome! 95 | 96 | ## Acknowledgments 97 | Special thanks to the creators of WSL for making tools like RunBash possible. 98 | -------------------------------------------------------------------------------- /setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo > "%temp%\msgbox" 3 | for /f %%i in (' dir /b RunBash*.exe ') do set "RunBash=%%~fi" 4 | "%RunBash%" -Install " " "C:\Users\benz\AppData\Local\Programs\Microsoft VS Code\Code.exe" 5 | "%RunBash%" -GetBin 6 | "%RunBash%" -AddBin ls ls --color=auto ; ll ls --color=auto -l ; la ls --color=auto -a ; lla ls --color=auto -la ; l ls --color=auto -CF 7 | "%RunBash%" -AddBin grep grep --color=auto ; fgrep fgrep --color=auto ; egrep egrep --color=auto ; ip ip --color=auto ; diff diff --color=auto 8 | "%RunBash%" -Help 9 | set "PATH=%PATH%;%ProgramData%\RunBash\Linux-Binary\" 10 | echo No Need To Restart Cmd, Enjoy :^) 11 | --------------------------------------------------------------------------------