From 904d47057987fcd2bc2bb9494758a611fa6ab2bc Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 14 Dec 2020 09:35:55 +0100 Subject: [PATCH] Pause on error from a wrapper script On Windows, scrcpy paused on error before exiting to give the user a chance to see the user message. This was a hack and causes issues when using scrcpy from batch scripts. Disable this pause from the scrcpy binary, and provide a batch wrapper (scrcpy-console.bat) to pause on error. Fixes #1875 --- Makefile.CrossWindows | 2 ++ app/src/main.c | 6 ------ data/scrcpy-console.bat | 4 ++++ 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 data/scrcpy-console.bat diff --git a/Makefile.CrossWindows b/Makefile.CrossWindows index 0415af82..f8a360d9 100644 --- a/Makefile.CrossWindows +++ b/Makefile.CrossWindows @@ -100,6 +100,7 @@ dist-win32: build-server build-win32 build-win32-noconsole cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN32_TARGET_DIR)/" cp "$(WIN32_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/" cp "$(WIN32_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN32_TARGET_DIR)/scrcpy-noconsole.exe" + cp data/scrcpy-console.bat "$(DIST)/$(WIN32_TARGET_DIR)" cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avutil-56.dll "$(DIST)/$(WIN32_TARGET_DIR)/" cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avcodec-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/" cp prebuilt-deps/ffmpeg-4.3.1-win32-shared/bin/avformat-58.dll "$(DIST)/$(WIN32_TARGET_DIR)/" @@ -115,6 +116,7 @@ dist-win64: build-server build-win64 build-win64-noconsole cp "$(SERVER_BUILD_DIR)"/server/scrcpy-server "$(DIST)/$(WIN64_TARGET_DIR)/" cp "$(WIN64_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/" cp "$(WIN64_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/scrcpy-noconsole.exe" + cp data/scrcpy-console.bat "$(DIST)/$(WIN64_TARGET_DIR)" cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avutil-56.dll "$(DIST)/$(WIN64_TARGET_DIR)/" cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avcodec-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/" cp prebuilt-deps/ffmpeg-4.3.1-win64-shared/bin/avformat-58.dll "$(DIST)/$(WIN64_TARGET_DIR)/" diff --git a/app/src/main.c b/app/src/main.c index d32d9896..71125673 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -98,11 +98,5 @@ main(int argc, char *argv[]) { avformat_network_deinit(); // ignore failure -#if defined (__WINDOWS__) && ! defined (WINDOWS_NOCONSOLE) - if (res != 0) { - fprintf(stderr, "Press Enter to continue...\n"); - getchar(); - } -#endif return res; } diff --git a/data/scrcpy-console.bat b/data/scrcpy-console.bat new file mode 100644 index 00000000..b90be29a --- /dev/null +++ b/data/scrcpy-console.bat @@ -0,0 +1,4 @@ +@echo off +scrcpy.exe %* +:: if the exit code is >= 1, then pause +if errorlevel 1 pause