Installing VS build tools with out any prompt

Varma 1,190 Reputation points
2024-04-21T05:57:43.6766667+00:00

I am using following script to VSbuild tools 2022, but what is happening it makes to go that folder and run manually even I have provided arguments in the below script which should not to prompt for window,

User's image

script:

Create the 'C:\software' directory if it doesn't exist

New-Item -ItemType Directory -Path 'C:\software' -Force

Change the current directory to 'C:\software'

Set-Location -Path 'C:\software'

Download the Visual Studio Build Tools installer

Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vs_BuildTools.exe' -UseBasicParsing -OutFile 'c:\software\vs_installer.exe'

Display a message indicating the start of installation

Write-Host 'Starting installation with selected components...'

Define the installation arguments

$arguments = '--quiet --norestart --nocache --wait --noupdateInstaller --noweb --add "Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools" --add "Microsoft.VisualStudio.Workload.WebBuildTools" --add "Microsoft.VisualStudio.Workload.AzureBuildTools" --add "Microsoft.VisualStudio.Workload.DataBuildTools" --includeRecommended'

Run the installer with the specified arguments

Start-Process -FilePath 'c:\software\vs_installer.exe' -Wait -ArgumentList $arguments

Please suggest way to install without asking for any prompt.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,672 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,399 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 26,481 Reputation points Microsoft Vendor
    2024-04-22T09:02:06.07+00:00

    Hello @Varma,

    I tried all the scripts you and Rich provided. None of the Visual Studio Installer prompts pop up when the scripts are run. The --quiet parameter prevents any user interface from being displayed when the script is executed.

    User's image

    If the installation is paused, please remove the --noweb parameter and try again.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Rich Matheisen 45,111 Reputation points
    2024-04-24T15:24:02.7033333+00:00

    Removing the --noupdateInstaller --noweb switches looks like it fixed your problem.

    It seems that determining the need to use those two switches is not as simple as it seems:

    https://stackoverflow.com/questions/62259223/visual-studio-2019-offline-layout-update-ignoring-noupdateinstaller

    https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022

    0 comments No comments