Install .NET 4 via command line or PowerShell?

24,697

Solution 1

I have done the following in Powershell:

((new-object net.webclient).DownloadFile("http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe","dotNetFx40_Full_x86_x64.exe")) 
& .\dotNetFx40_Full_x86_x64.exe /q

There are other command line options than /q (for quiet). You can see those by doing:

& .\dotNetFx40_Full_x86_x64.exe /?

MessageBox resulting from running installer with the /? switch

Solution 2

This isn't specific to powershell, but might be of help. After installing .NET3.5 we follow up using the full install binaries, simply running a silent install. Depending on what and how you install this may require a reboot.

This how I've run silent installs of .NET4 in build/update scripts on 2003-2008R2 servers using the full install package:

  • dotNetFx40_Full_x86_x64.exe /q

If you've not already stumbled across these, you might find them useful:

Share:
24,697

Related videos on Youtube

house9
Author by

house9

Updated on September 18, 2022

Comments

  • house9
    house9 almost 2 years

    How do I install .NET 4 on Windows Server 2008 R2 from the command line or PowerShell?

    This post shows how to do it for .NET 3.5 using dism.exe and PowerShell. I am guessing that, since the .NET 4.0 binaries need to be downloaded first, these instructions do not work for .NET 4.

    • Ryan Bolger
      Ryan Bolger about 13 years
      Do you mean 2008 R2? Or do you actually mean RC2 as in a release candidate?
    • house9
      house9 about 13 years
      R2 - sorry about that
    • Ryan Bolger
      Ryan Bolger about 13 years
      Your question might get more views if you edit it to fix the mistake. You should also probably update your windows-server-2008 tag to windows-server-2008-r2.
  • Steve
    Steve almost 12 years
    When I run /? I get nothing ...
  • steenhulthin
    steenhulthin almost 12 years
    Are you on a windows core system (with no GUI)? The help pops up in a window on my machine. Can you run the installer without the /? switch?
  • steenhulthin
    steenhulthin almost 12 years
    The only other thing I can think of is that you don't have permissions to run the installer.
  • Steve
    Steve almost 12 years
    I may not have let it get that far? I expect those sorts of windows to come up right away, and instead it started rolling scrollbars, etc.
  • steenhulthin
    steenhulthin almost 12 years
    :) I agree that solution Microsoft came up with here is not really elegant. It is quite clunky to get a message box returned from a command line command.
  • Steve
    Steve almost 12 years
    Thanks for the updated picture, however, and it a) answered my question and b) should help others.
  • Joel Coel
    Joel Coel over 8 years
    There's also Invoke-WebRequest for downloading files.