1

I'm trying to install IIS7+ programmically. If I run it directly in the cmd prompt, it runs fine.

start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

Because of the "start" part at the beginning, I'm a little confused on how to run it ServiceProcess.Process class. I can run any other exe that I've needed but pkgmgr.exe doesn't see to play nice.

Using proc As New Process()
    proc.StartInfo.FileName = "c:\windows\system32\pkgmgr.exe"
    proc.StartInfo.Arguments = "/l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI"
    proc.Start()
    proc.WaitForExit()
End Using
RichC
  • 7,829
  • 21
  • 85
  • 149
  • 1
    What do you mean by "doesn't seem to play nice"? Are you getting an error? If so, what is it? – Justin Helgerson Apr 19 '13 at 03:10
  • Why are you trying to install this from your application? Normally your apps will not have the correct permissions to do this and it isn't recommended to do this from a security perspective. – tsells Apr 19 '13 at 04:06
  • @Geek It's enterprise software that is usually installed on a brand new dedicated server and many of our customers complain about having to do the tedious configurations for our installations. – RichC Apr 19 '13 at 13:08
  • @Ek0nomik - it's doesn't nothing and no errors but I'm not doing anything other than what is in the code that I shared in a simple winform app on a button click event run as administrator. – RichC Apr 19 '13 at 13:08
  • We have to do the same thing with our packages. There are always manual steps required to set it up. For one - with IIS you should never just turn it on and leave it alone. There are security protocols, configurations, etc that should be considered when enabling the feature - and by installing it yourself - you leave your clients open to potential issues in their environment. It's best to let them do the setup up front for the "dependencies" your software has. – tsells Apr 19 '13 at 16:16

1 Answers1

1

I found this trustworthy link Using Unattended Setup to Install IIS 7.0

STEP 1: PKGMGR.EXE OVERVIEW

Windows Optional features in Vista/Windows Server 2008 is installed using a new command tool called Pkgmgr. The command line syntax using pkgmgr.exe is:

Start /w pkgmgr.exe /iu:update1;update2… 

Pkgmgr.exe Commands

/iu:{update name}; This specifies updates to install by update name and takes a semicolon separated name of updates to install.

/uu:{update name}; This specifies the updates to uninstall and takes a semicolon separated list of selectable updates to be uninstalled from the system. At least one update name must be specified

/n:{unattend XML} This specifies file name of the unattend XML file.

Please see the MSDN article for further details about the XML file.


eg:

To install only the IIS 7.0 default features, copy the following unattend.xml text into notepad.

<?xml version="1.0" ?> 
<unattend xmlns="urn:schemas-microsoft-com:unattend"  
    xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<servicing> 
   <!-- Install a selectable update in a package that is in the Windows Foundation namespace --> 
   <package action="configure"> 
      <ssemblyIdentity 
         name="Microsoft-Windows-Foundation-Package"
         version="6.0.5308.6"
         language="neutral"
         processorArchitecture="x86"
         publicKeyToken="31bf3856ad364e35"
         versionScope="nonSxS"
      />
    <selection name="IIS-WebServerRole" state="true"/> 
    <selection name="WAS-WindowsActivationService" state="true"/> 
    <selection name="WAS-ProcessModel" state="true"/> 
    <selection name="WAS-NetFxEnvironment" state="true"/> 
    <selection name="WAS-ConfigurationAPI" state="true"/> 
  </package> 
</servicing> 
</unattend> 
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • Yeah, I referenced this as well but doesn't seem to work from C# app which you don't reference in your answer. As I mentioned in my post, I can run this code fine from cmd prompt. It's running it from c# that is the issue. – RichC Apr 19 '13 at 13:11
  • 1
    Are you running the C# app as an administrator? If you are debugging - Visual Studio must be run in admin mode. – tsells Apr 22 '13 at 00:06
  • Yes, visual studio and the app is run as administrator. – RichC Apr 22 '13 at 03:33
  • @RichC follow this: http://stackoverflow.com/questions/16079030/better-way-to-install-iis7-programmatically – Jeremy Thompson Apr 25 '13 at 04:00