Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Created February 24, 2015 14:41
Show Gist options
  • Save primaryobjects/c24803bed23f4a6dacd4 to your computer and use it in GitHub Desktop.
Save primaryobjects/c24803bed23f4a6dacd4 to your computer and use it in GitHub Desktop.
DOS batch file to launch a NodeWebKit app. NodeWebKit has a habit of occasionally immediately quitting when trying to launch it. This script times the launch and quit times, so if the app exits in less than 5 seconds, we re-launch the app, until we finally get a proper launch.
@echo off
:loop
:: Start timer.
@set /A _tic=%time:~0,2%*3600^
+%time:~3,1%*10*60^
+%time:~4,1%*60^
+%time:~6,1%*10^
+%time:~7,1% >nul
:: Launch NodeWebKit on the app in the current folder.
start /wait %~dp0\node_modules\nw\nwjs\nw .
:: Stop timer.
@set /A _toc=%time:~0,2%*3600^
+%time:~3,1%*10*60^
+%time:~4,1%*60^
+%time:~6,1%*10^
+%time:~7,1% >nul
:: Get elapsed seconds.
@set /A _elapsed=%_toc%-%_tic
@echo %_elapsed% seconds.
if %_elapsed% leq 4 goto loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment