mirror of
https://github.com/winapps-org/winapps.git
synced 2025-08-06 10:48:27 +02:00
various improvements to install.bat
This commit is contained in:
@@ -1,25 +1,66 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
title WinApps Setup Wizard
|
||||||
|
|
||||||
reg import %~dp0\RDPApps.reg
|
REM Check for administrative privileges
|
||||||
|
fltmc >nul 2>&1 || (
|
||||||
if exist %~dp0\Container.reg (
|
echo [INFO] Script not running as administrator. Attempting to relaunch with elevation...
|
||||||
reg import %~dp0\Container.reg
|
powershell -Command "Start-Process '%~f0' -Verb runAs"
|
||||||
|
exit /b 0
|
||||||
)
|
)
|
||||||
|
|
||||||
REM Create network profile cleanup scheduled task
|
REM Confirm the user wants to proceed with setup
|
||||||
copy %~dp0\NetProfileCleanup.ps1 %windir%
|
echo ============================================
|
||||||
set "taskname=NetworkProfileCleanup"
|
echo WinApps Setup Wizard
|
||||||
set "command=powershell.exe -ExecutionPolicy Bypass -File "%windir%\NetProfileCleanup.ps1^""
|
echo ============================================
|
||||||
|
echo.
|
||||||
|
echo Press any key to continue or close this window to cancel...
|
||||||
|
pause >nul
|
||||||
|
echo.
|
||||||
|
echo [INFO] Starting setup...
|
||||||
|
|
||||||
schtasks /query /tn "%taskname%" >nul 2>&1
|
REM Apply RDP and system configuration tweaks
|
||||||
|
echo [INFO] Importing "RDPApps.reg"...
|
||||||
|
reg import "%~dp0RDPApps.reg" >nul 2>&1
|
||||||
if %ERRORLEVEL% equ 0 (
|
if %ERRORLEVEL% equ 0 (
|
||||||
echo Task "%taskname%" already exists, deleting it first...
|
echo [SUCCESS] Imported "RDPApps.reg".
|
||||||
schtasks /delete /tn "%taskname%" /f
|
|
||||||
)
|
|
||||||
|
|
||||||
schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f
|
|
||||||
if %ERRORLEVEL% equ 0 (
|
|
||||||
echo Scheduled task "%taskname%" created successfully.
|
|
||||||
) else (
|
) else (
|
||||||
echo Failed to create scheduled task.
|
echo [ERROR] Failed to import "RDPApps.reg".
|
||||||
)
|
)
|
||||||
|
|
||||||
|
REM Configure the system clock to use UTC instead of local time
|
||||||
|
if exist "%~dp0Container.reg" (
|
||||||
|
echo [INFO] Importing "Container.reg"...
|
||||||
|
reg import "%~dp0Container.reg" >nul 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 (
|
||||||
|
echo [SUCCESS] Imported "Container.reg".
|
||||||
|
) else (
|
||||||
|
echo [ERROR] Failed to import "Container.reg".
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo [WARNING] "Container.reg" not found. Skipping...
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Create a startup task to clean up stale network profiles
|
||||||
|
echo [INFO] Creating network profile cleanup task...
|
||||||
|
|
||||||
|
REM Initialise values required to create the startup task
|
||||||
|
set "scriptpath=%windir%\NetProfileCleanup.ps1"
|
||||||
|
set "taskname=WinApps_NetworkProfileCleanup"
|
||||||
|
set "command=powershell.exe -ExecutionPolicy Bypass -File ""%scriptpath%"""
|
||||||
|
|
||||||
|
REM Copy the script to the Windows directory
|
||||||
|
copy /Y "%~dp0NetProfileCleanup.ps1" "%scriptpath%" >nul
|
||||||
|
if %ERRORLEVEL% neq 0 (
|
||||||
|
echo [ERROR] Failed to copy "NetProfileCleanup.ps1" to "%windir%".
|
||||||
|
) else (
|
||||||
|
schtasks /create /tn "%taskname%" /tr "%command%" /sc onstart /ru "SYSTEM" /rl HIGHEST /f >nul 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 (
|
||||||
|
echo [SUCCESS] Created scheduled task "%taskname%".
|
||||||
|
) else (
|
||||||
|
echo [ERROR] Failed to create scheduled task "%taskname%".
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Press any key to exit...
|
||||||
|
pause >nul
|
Reference in New Issue
Block a user