http://sojoe.info/2006/11/01/silent-install-of-ms-net-framework-version-2/
Many applications now require Microsoft .NET Framework Version 2.0 (I’ll call it .NET2 for short), and it is one of the recommended updates if you go to Windows Update or Microsoft Update. If you’re building a silent distribution of Windows XP, or any applications to install on Windows XP, then you’ll want to be able to silently install .NET2. Following are instructions on one way of doing this (their’s always another way).
First, you’ll need to download .NET2 from Microsoft. All of the links to downloads assume you are using the more common 32-bit version of the English version of Windows XP. You can get the download here:
By default, double-clicking the dotnetfx.exe file you downloaded will unpack it to a temp directory, and then give you an interface to click through for the installation. We don’t want to have to click all those buttons, we’d prefer a silent installation. The available command-line switches for this download are:
- /Q Quiet modes for package
- /T:
Specifies temporary working folder - /C Extract files only to the folder when used also with /T
- /C:
Override Install Command defined by author
I originally didn’t know how to get the downloaded file to install silently by itself, so in the blockquote below you’ll see instructions on how to extract the file and then install the components silently. Thankfully, a reader suggested a command-line that works with the original downloaded file, so I’ll explain the simpler method instead, as the process is much easier. I’ve retained the original instructions below in blockquote in case something in that method lends itself to your particular situation.
So, you’ve got the dotnetfx.exe file, now we need to tell it how to install silently. You could use the ‘Run’ command under the Start Menu to do this, but you’d have to type the full command in each time you wanted to do an install, which isn’t going to save much time. Instead, let’s create a batch file that we can simply double-click, and the rest will happen silently. We’re going to want to have all the necessary files together in one directory, so create a directory called ‘dotnet2′ (you can use a different name, and put it in any location that is convenient).
So, in the ‘dotnet2′ directory, right-click on a blank spot and from the pop-up menu choose ‘New’ and then ‘Text Document’. A file will be created and will want you to name it, call it ‘Install.bat’. You’ll be asked if you’re sure you want to change the extension, answer ‘Yes’. Now, right-click the Install.bat file you just created and choose ‘Edit’. A blank window will open, probably Notepad, where you can now type in the commands you want to include.
I generally start my batch files with some text that will appear on the script window explaining what’s going on, so I’ll start with this:
@ECHO OFF ECHO Installing DotNet 2
The first line tells the window not to show ever single step we take, and the second shows the text ‘Installing DotNet 2′.
Next, we’ll tell the install file to run. As long as the Install.bat file is in the same directory as the install.exe file, we don’t need to specify the path:
start /wait dotnetfx.exe /q:a /c:"install.exe /q"
Notice that I used the /q switch, which initiates the ‘quiet mode’, and the /c switch to pass along a command line switch to the files which will be extracted, so the magic part that wasn’t clear from the start was the additional ‘:a’ following the /q switch. The ’start /wait’ part simply tells the window to stay open until the installation is finished, which is useful if you want to know if it’s still running, and also useful if you’ll be doing anything else with the script after the installation. What, you thought this was it? Nope, their’s more. You now have a script that will install .NET2 silently on any machine, but their are patches available for .NET which should be applied as well. As I write this, their are two patches available:
- KB917283
- http://www.microsoft.com/downloads/details.aspx?familyid=56A1777B-9758-489F-8BE8-5177AAF488D1&displaylang=en
- Download NDP20-KB917283-X86.exe
- KB922770
- http://www.microsoft.com/downloads/details.aspx?familyid=34C375AA-2F54-4416-B1FC-B73378492AA6&displaylang=en
- Download NDP20-KB922770-X86.ex
These files have the following command-line switches:
- /extract
Extract files to the directory specified - /q Quiet install mode
The ‘Quiet mode’ does work on these, so the process is pretty simple, just run each of the exe’s with the /q switch, and you are just about done. All you need to do is add one more command to tell the command window to go away when it’s done. Just add an ‘exit’ at the end.
So, your final Install.bat script will probably look like this:
@ECHO OFF
ECHO Installing DotNet 2
start /wait dotnetfx.exe /q:a /c:"install.exe /q"
start /wait NDP20-KB917283-X86.exe /q
start /wait NDP20-KB922770-X86.exe /q
exit
Copy your dotnet2 folder to a network share, or throw it on a CD or thumbdrive and all you need to do is double-click the Install.bat file or call it from another batch file and Microsoft .NET Framework Version 2.0 will silently install with patches on that computer. When the black command window disappears, it’s installed.
Here’s the previous method, which works, but is a little more complicated:
Notice their is a switch for ‘Quiet mode’, which you’d think would be the same as ‘Silent Install’, but if you try it, you’ll find you get the same prompts as a normal installation. So, what we’ll need to do is extract the files from this download. You can do this by using the /C and /T switches. Probably the easiest way to do this part is to go to your Start Menu and choose ‘Run’. When the run window opens, clear any text that might be in the ‘Open’ field, and then drag the dotnetfx.exe file into it, which will automatically type in the path to the file (you can also use the browse button to go find it). Now, before you click ‘OK’, add the following after the name of the file ” /C /T:c:\dotnet2″. If you had downloaded the dotnetfx.exe file to your desktop, you’re Run box whould look something like this:
“C:\Documents and Settings\username\Desktop\dotnetfx.exe” /C /T:c:\dotnet2
Click OK and this will instruct the file to expand to a directory on your C: drive named ‘dotnet2′. You can change the ‘c:\dotnet2′ part to any location that is convenient, but if it contains spaces you’ll need to wrap it in quotes.
So, now you’ve got a bunch of files at c:\dotnet2. Open that directory and you’ll see one of the files is named ‘Install.exe’. That’s the file we’ll be using to do our silent installation. It has some command-line switches as well:
- /l Name of verbose msi log
- /lang
4-digit language code - /q Quiet install mode
- /qu Quiet uninstall mode
The /q switch is the one we’re looking for. Now we could use the ‘Run’ command to do this, but it would only help us on this one machine. If we want a hands-off approach on other machines as well, we’ll want to create a script to tell the install.exe file what to do. So, in the ‘c:\dotnet2′ directory, right-click on a blank spot and from the pop-up menu choose ‘New’ and then ‘Text Document’. A file will be created and will want you to name it, call it ‘Install.bat’. You’ll be asked if you’re sure you want to change the extension, answer ‘Yes’. Now, right-click the Install.bat file you just created and choose ‘Edit’. A blank window will open, probably Notepad, where you can now type in the commands you want to include.
I generally start my batch files with some text that will appear on the script window explaining what’s going on, so I’ll start with this:
@ECHO OFF ECHO Installing DotNet 2
The first line tells the window not to show ever single step we take, and the second shows the text ‘Installing DotNet 2′.
Next, we’ll tell the install file to run. As long as the Install.bat file is in the same directory as the install.exe file, we don’t need to specify the path:
start /wait install.exe /q
The ’start /wait’ part simply tells the window to stay open until the installation is finished, which is useful if you want to know if it’s still running, and also useful if you’ll be doing anything else with the script after the installation. What, you thought this was it? Nope, their’s more. You now have a script that will install .NET2 silently on any machine, but their are patches available for .NET which should be applied as well. As I write this, their are two patches available:
- KB917283
- http://www.microsoft.com/downloads/details.aspx?familyid=56A1777B-9758-489F-8BE8-5177AAF488D1&displaylang=en
- Download NDP20-KB917283-X86.exe
- KB922770
- http://www.microsoft.com/downloads/details.aspx?familyid=34C375AA-2F54-4416-B1FC-B73378492AA6&displaylang=en
- Download NDP20-KB922770-X86.ex
These files have the following command-line switches:
- /extract
Extract files to the directory specified - /q Quiet install mode
The ‘Quiet mode’ does work on these, so the process is pretty simple, just run each of the exe’s with the /q switch, and you are just about done. All you need to do is add one more command to tell the command window to go away when it’s done. Just add an ‘exit’ at the end.
So, your final Install.bat script will probably look like this:
@ECHO OFF ECHO Installing DotNet 2 start /wait install.exe /q start /wait NDP20-KB917283-X86.exe /q start /wait NDP20-KB922770-X86.exe /q exit
Copy your c:\dotnet2 folder to a network share, or throw it on a CD or thumbdrive and all you need to do is double-click the Install.bat file or call it from another batch file and Microsoft .NET Framework Version 2.0 will silently install with patches on that computer. When the black command window disappears, it’s installed.
'Program > C#' 카테고리의 다른 글
[ASP.NET] Referrer 속성으로 사이트 방문시 유입 경로 알아내기 (0) | 2010.03.05 |
---|---|
주사위놀이 (0) | 2010.02.09 |
텍스트박스에 워터 마크 추가(배경) (0) | 2010.01.26 |
윈도우 폼 간 도킹 기능 (0) | 2010.01.26 |
윈폼 파일 드레그하기 (0) | 2010.01.26 |