-
-
Save kasajian/1348cef4f23d322c4b7f24471849d2d0 to your computer and use it in GitHub Desktop.
A single batch file that downloads a nodejs binary and runs the code embedded in itself. (for windows 7 and above)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ("0"=="1") /* | |
@echo off | |
set args=%* | |
setlocal ENABLEDELAYEDEXPANSION | |
if not exist %TEMP%\node.exe ( | |
echo DOWNLOADING RUNTIME... | |
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://nodejs.org/dist/latest/win-x64/node.exe', '%TEMP%\node.exe')" | |
echo DOWNLOAD COMPLETE! | |
) | |
echo STARTING EMBEDDED APPLICATION | |
call :NODE_JS | |
goto :EOF | |
:NODE_JS | |
%TEMP%\node.exe "%~f0" %args% | |
pause | |
exit /b | |
*/ {} | |
// Javascript starts here | |
function nodeMain(){ | |
console.log('Hello, NodeJS', process.version); | |
console.log(process.argv.slice(2)); | |
} | |
nodeMain(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment