-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLaunch-HMIS-Fullscreen.bat
More file actions
82 lines (70 loc) · 3.19 KB
/
Launch-HMIS-Fullscreen.bat
File metadata and controls
82 lines (70 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@echo off
setlocal enabledelayedexpansion
REM HMIS Desktop Chrome App Launcher - Fullscreen Mode
REM Load configuration
call "%~dp0config.bat"
REM Determine session directory based on SESSION_MODE
if "%SESSION_MODE%"=="PERSISTENT" (
set USER_DATA_DIR=%SESSION_DIR%\PersistentSession
set SESSION_ID=PERSISTENT
) else (
if "%SESSION_MODE%"=="TEMPLATE" (
REM Generate unique session ID using timestamp
set SESSION_ID=%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set SESSION_ID=!SESSION_ID: =0!
set USER_DATA_DIR=%SESSION_DIR%\Session_!SESSION_ID!
set TEMPLATE_DIR=%SESSION_DIR%\TemplateProfile
REM Check if template exists
if exist "!TEMPLATE_DIR!" (
REM Copy template to new session
echo Copying template profile to new session...
xcopy "!TEMPLATE_DIR!" "!USER_DATA_DIR!" /E /I /Q >nul 2>&1
) else (
REM First launch - create template
echo First launch - creating template profile...
echo Configure your printer settings, then close and relaunch.
set USER_DATA_DIR=!TEMPLATE_DIR!
set SESSION_ID=TEMPLATE_SETUP
)
) else (
REM Generate unique session ID using timestamp
set SESSION_ID=%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set SESSION_ID=!SESSION_ID: =0!
set USER_DATA_DIR=%SESSION_DIR%\Session_!SESSION_ID!
)
)
REM Build Chrome command
set CHROME_CMD="C:\Program Files\Google\Chrome\Application\chrome.exe"
set CHROME_ARGS=--app="%HMIS_URL%" --user-data-dir="!USER_DATA_DIR!" --kiosk --no-first-run --no-default-browser-check --load-extension="%~dp0print-extension"
REM Apply print mode settings
if "%PRINT_MODE%"=="DIRECT" (
set CHROME_ARGS=!CHROME_ARGS! --disable-print-preview
)
if "%PRINT_MODE%"=="SILENT" (
set CHROME_ARGS=!CHROME_ARGS! --kiosk-printing
)
REM Apply cache settings
if "%CACHE_MODE%"=="DISABLED" (
set CHROME_ARGS=!CHROME_ARGS! --disk-cache-dir=nul --disk-cache-size=1
)
REM Apply zoom level if set
if not "%ZOOM_LEVEL%"=="" (
set CHROME_ARGS=!CHROME_ARGS! --force-device-scale-factor=%ZOOM_LEVEL%
)
REM Create user data directory if it doesn't exist
if not exist "!USER_DATA_DIR!" mkdir "!USER_DATA_DIR!"
REM Configure print preferences
set PREFS_DIR=!USER_DATA_DIR!\Default
if not exist "!PREFS_DIR!" mkdir "!PREFS_DIR!"
REM Only create Preferences file if it doesn't exist (preserve user settings)
if not exist "!PREFS_DIR!\Preferences" (
echo Creating initial Preferences file with print settings...
powershell -Command "$prefs = @{printing=@{print_preview_sticky_settings=@{appState=@{version=2;recentDestinations=@();selectedDestinationId='';marginsType=3;customMargins=@{marginTop=0;marginBottom=0;marginLeft=0;marginRight=0};isHeaderFooterEnabled=$false;isLandscapeEnabled=$false;scaling='100';scalingType=0;isCssBackgroundEnabled=$true}}}}; $prefs | ConvertTo-Json -Depth 10 | Out-File -FilePath '!PREFS_DIR!\Preferences' -Encoding utf8"
)
REM Launch Chrome
start "" !CHROME_CMD! !CHROME_ARGS!
echo HMIS Fullscreen Session: !SESSION_ID!
echo Session Mode: !SESSION_MODE!
echo Print Mode: !PRINT_MODE!
timeout /t 2 >nul
exit