@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------    


@echo off
setlocal enabledelayedexpansion

::Sync internet time
w32tm /register
net start w32time
w32tm /resync

:: TODOS -- Add function to install printer // Add NinjaRMM Agents, Choice. 

:: Run a PowerShell script -- Rename PC script
set "powershellScript=%~dp0\RenamePC.ps1"  :: Replace with your actual PowerShell script path

if exist "%powershellScript%" (
    echo Running PowerShell script "%powershellScript%"...
    powershell -ExecutionPolicy Bypass -File "%powershellScript%"
    if %errorlevel% neq 0 (
        echo PowerShell script execution failed.
    ) else (
        echo PowerShell script executed successfully.
    )
) else (
    echo PowerShell script "%powershellScript%" does not exist.
)




:: Prompt for Administrator Password
echo **********************************
set /p password="Enter the Administrator password (Leave blank to bypass): "

:: Enable Administrator and set password
net user Administrator %password% /active

:: Remove the user account from administrators localgroup
net localgroup administrators %username% /delete

:: Add the %username% account to users localgroup
net localgroup users %username% /add


:: Copy Lexmark Driver Folder to C: root
set "sourceFolder=%~dp0\LexmarkUniversalv2"  :: Replace with your actual source folder path
set "destinationFolder=C:\LexmarkUniversalV2"  :: Replace with your actual destination folder path

if exist "%sourceFolder%" (
    echo Copying folder from "%sourceFolder%" to "%destinationFolder%"...
    xcopy "%sourceFolder%" "%destinationFolder%" /E /I /Y
    if %errorlevel% neq 0 (
        echo Failed to copy the folder.
    ) else (
        echo Folder copied successfully.
    )
) else (
    echo Source folder "%sourceFolder%" does not exist.
)



:: Run a PowerShell script - Win11Debloat
set "powershellScript=%~dp0\Win11Debloat\Win11Debloat.ps1"  :: Replace with your actual PowerShell script path

if exist "%powershellScript%" (
    echo Running PowerShell script "%powershellScript%"...
    powershell -ExecutionPolicy Bypass -File "%powershellScript%" -RemoveAppsCustom -DisableTelemetry -DisableBing -DisableSuggestions -DisableLockscreenTips -RevertContextMenu -ShowKnownFileExt -HideDupliDrive -HideTaskview -HideChat -DisableWidgets -DisableCopilot -HideOnedrive -Hide3dObjects -HideMusic -DisableDVR -ClearStartAllUsers -Silent
    if %errorlevel% neq 0 (
        echo PowerShell script execution failed.
    ) else (
        echo PowerShell script executed successfully.
    )
) else (
    echo PowerShell script "%powershellScript%" does not exist.
)


echo ********************************************************************
powershell -ExecutionPolicy Bypass -File %~dp0\Render-String.ps1 "COMPLETE" -FontName "Consolas" -FontSize 15 -Fill #
echo ********************************************************************



echo All tasks completed.
PAUSE
endlocal



