buildtoolsinstallerfixed

This commit is contained in:
jazir5 2024-06-19 18:21:57 -07:00 committed by GitHub
parent fe0cc868e8
commit 6c3db27515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,17 +20,27 @@ if %errorlevel% neq 0 (
set exe_name=CustomLogonUI.exe
set cpp_code=CustomLogonUI.cpp
set src_path=%~dp0
set log_file=%~dp0modify_winlogon.log
set dst_path=C:\Windows\System32
set backup_logonui=logonui_backup.exe
set temp_dir=C:\Temp
set installer=%temp_dir%\vs_buildtools.exe
set vs_install_log=%temp_dir%\vs_buildtools_install.log
set vs_install_error_log=%temp_dir%\vs_buildtools_install_error.log
echo Script started at %date% %time% > %log_file%
echo Script started at %date% %time%
:: Step 1: Ensure Temp Directory Exists and has Correct Permissions
:: Ensure Temp Directory Exists and has Correct Permissions
echo Ensuring temp directory exists and has correct permissions... >> %log_file%
if not exist "%temp_dir%" (
mkdir "%temp_dir%"
)
icacls "%temp_dir%" /grant Everyone:(F) >> %log_file% 2>&1
if %errorlevel% neq 0 (
echo Failed to set permissions for the temp directory. >> %log_file%
pause
exit /b
)
echo Temp directory permissions set. >> %log_file%
:: Step 2: Install .NET Framework 4.8 (NetFx4-AdvSrvs)
@ -118,30 +128,31 @@ if %errorlevel% neq 0 (
echo Visual Studio Community installed successfully. >> %log_file%
echo Visual Studio Community installed successfully.
:: Step 3: Check for Visual Studio Build Tools
echo Checking for Visual Studio Build Tools... >> %log_file%
reg query "HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7" >nul 2>&1
:: Download Visual Studio Build Tools Installer
set installer=%temp_dir%\vs_buildtools.exe
echo Downloading Visual Studio Build Tools... >> %log_file%
powershell -Command "Invoke-WebRequest -Uri 'https://aka.ms/vs/16/release/vs_buildtools.exe' -OutFile '%installer%'" >> %log_file% 2>&1
if %errorlevel% neq 0 (
echo Visual Studio Build Tools not found. Downloading... >> %log_file%
powershell -Command "$installer='%temp_dir%\vs_buildtools.exe'; Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vs_buildtools.exe -OutFile $installer; Start-Process -Wait -FilePath $installer -ArgumentList '--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive --norestart'; Remove-Item -Force $installer"
if %errorlevel% neq 0 (
echo Failed to download Visual Studio Build Tools installer. >> %log_file%
echo Failed to download Visual Studio Build Tools installer.
pause
exit /b
)
echo Running Visual Studio Build Tools installer... >> %log_file%
start /wait "" "%installer%" --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive --norestart >> %log_file% 2>&1
if %errorlevel% neq 0 (
echo Failed to install Visual Studio Build Tools. >> %log_file%
echo Failed to install Visual Studio Build Tools.
pause
exit /b
)
echo Visual Studio Build Tools installed successfully. >> %log_file%
) else (
echo Visual Studio Build Tools are already installed. >> %log_file%
echo Failed to download Visual Studio Build Tools installer. >> %log_file%
pause
exit /b
)
echo Visual Studio Build Tools installer downloaded successfully. >> %log_file%
:: Run Visual Studio Build Tools Installer
echo Running Visual Studio Build Tools installer... >> %log_file%
powershell -Command "Start-Process -Wait -FilePath '%installer%' -ArgumentList '--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended --passive --norestart' -RedirectStandardOutput '%vs_install_log%' -RedirectStandardError '%vs_install_error_log%' -NoNewWindow" >> %log_file% 2>&1
if %errorlevel% neq 0 (
echo Failed to install Visual Studio Build Tools. >> %log_file%
echo Check the install log for details: %vs_install_log% and %vs_install_error_log% >> %log_file%
pause
exit /b
)
echo Visual Studio Build Tools installed successfully. >> %log_file%
:: Indicate end of script
echo Script completed successfully. >> %log_file%
pause
:: Step 5: Create the C++ source file using PowerShell
echo Creating C++ source file using PowerShell... >> %log_file%