Script to install Remote System Administration Tools (RSAT) for Windows 7 with Service Pack 1

Here is a quick script to just install, or install and enable the Windows 7 Remote System Administration Tools (RSAT) for Windows 7 with Service Pack 1. I created it for use with the software deployment functionality in System Center Configuration Manager, but it is not limited to that.

' InstallRSAT.vbs
' v 1.0 (15.06.2011)
' by Morgan Simonsen, Atea
' 
' Detects system architecture, and installs and enables RSAT for Windows 7 with SP1, depending on submitted arguments.
'
' Usage:
' InstallRSAT.vbs <Install|InstallAndEnable>
'
' Install: just install RSAT, must be manually enabled
' InstallAndEnable: install and enable RSAT (all components)
'
' If no arguments are submitted; Install will be used.
'
' Arguments are CASE SENSITIVE!!!
 
'Enable/disable debugging
strDebug = 0
 
Set objWSHShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
'Get script arguments
Set objArgs = WScript.arguments
 
If objArgs.Count = 0 Then
    ' No arguments submitted, defaulting to install (and not enable)
    strInstallAction = "/Install"
Else
    strInstallAction = objArgs.item(0)
    Select Case strInstallAction
        Case "/Install"
            'Install action selected
        Case "/InstallAndEnable"
            'InstallAndEnable action selected
        Case Else
            'Invalid argument submitted; quitting!
    End Select
End If
 
strScriptPath = objFSO.GetParentFolderName(WScript.ScriptFullName)
 
'Determine CPU Architecture
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
 
Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objProcessor in colProcessors
    strProcessorArchitecture = objProcessor.Architecture
Next
 
'strProcessorArchitecture = objWSHShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
strWinDir = objWSHShell.ExpandEnvironmentStrings("%WINDIR%")
 
strWUSA = strWinDir & "system32wusa.exe"
strDISM = strWinDir & "system32dism.exe"
strx86Package = strScriptPath & "Windows6.1-KB958830-x86-RefreshPkg.msu"
strx64Package = strScriptPath & "Windows6.1-KB958830-x64-RefreshPkg.msu"
 
Select Case strProcessorArchitecture
    Case "0"
        strProcessorArchitectureHumanReadable = "x86"
        strLogFile = chr(34) & strWinDir & "LogsRSAT Install (" & strProcessorArchitectureHumanReadable & ").log" & Chr(34)
        objWSHShell.Run (strWUSA & " " & strx86Package & " /quiet /norestart /log:" & strLogFile),0,True
        If strInstallAction = "/InstallAndEnable" Then
            Call EnableRSAT()
        End If
    Case "9"
        strProcessorArchitectureHumanReadable = "x64"
        strLogFile = chr(34) & strWinDir & "LogsRSAT Install (" & strProcessorArchitectureHumanReadable & ").log" & Chr(34)
        objWSHShell.Run (strWUSA & " " & strx64Package & " /quiet /norestart /log:" & strLogFile),0,True
        If strInstallAction = "/InstallAndEnable" Then
            Call EnableRSAT()
        End If
    Case Else
        'Unknown architecture; quitting!
End Select
 
Function EnableRSAT()
            objWSHShell.Run (strDISM & " /Online /Enable-Feature " &_
            "/FeatureName:IIS-LegacySnapIn " &_
            "/FeatureName:IIS-IIS6ManagementCompatibility " &_
            "/FeatureName:IIS-WebServerManagementTools " &_
            "/FeatureName:IIS-WebServerRole " &_
            "/FeatureName:IIS-Metabase " &_
            "/FeatureName:RemoteServerAdministrationTools " &_
            "/FeatureName:RemoteServerAdministrationTools-ServerManager " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-CA " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-OnlineResponder " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-DS " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-NIS " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-LDS " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-DHCP " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-DNS " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-FileServices " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Dfs " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Fsrm " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-FileServices-StorageMgmt " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-HyperV " & _
            "/FeatureName:RemoteServerAdministrationTools-Roles-RDS " & _
            "/FeatureName:RemoteServerAdministrationTools-Features " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-BitLocker " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-Clustering " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-GP " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-LoadBalancing " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-SmtpServer " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-StorageExplorer " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-StorageManager " & _
            "/FeatureName:RemoteServerAdministrationTools-Features-Wsrm"),0,True
End Function
 
Function Debug(data)
    If strDebug = 1 Then
        WScript.Echo data
    End If
End Function

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Join the Conversation

3 Comments

  1. Hello Morgan

    This is just the script I’m looking for, the only problem is that the right-hand is cut-off on the page above.

    Any chance you could repost the script and wrap the lines please?

    Many thanks

  2. Sorry Morgan, ignore….When I copied it inot Notepad it was all there…..

  3. Hi there,

    Just wanted to know why you dont have a plug-in for displaying code? its very useful to have on your wordpress site. I personally use SyntaxHighlighter Evolved that does the trick.

    Cheers,
    ivan

Leave a comment

Your email address will not be published. Required fields are marked *