I'm trying to install IIS via DISM. When executing the command either via code or directly in cmd prompt, it appears to run fine, but IIS is never installed. I'm unsure where I went wrong. Sorry for the block of text in the code. I've tried running just one of the features with the same result and I need all of these installed for my purposes.
START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-ManagementConsole /FeatureName:IIS-Metabase /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-DefaultDocument /FeatureName:IIS-IIS6ManagementConsole /FeatureName:IIS-StaticContent /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerRole
Try running dism.exe without Start /wait, you will actually see the errors, IIS-IIS6ManagementConsole is not a known feature, there is no IIS6 management console in IIS7+. The next problem I got is with IIS-NetFxExtensibility, it is missing parent features, try adding the /all switch to also enable required features.
Related
All the solutions I can find on this topic are very old and none of them appear to answer my question...
I am trying to create a windows service that can self update (or auto update by some external trigger). In the past, I had created a windows service that was installed with InstallShield and we were able to update auto update the service in a hacky way by making the service write a batch script to the local machine and then run the batch script, which would stop the service, overwrite the service executable and other files with the new ones, and restart the service. This surprisingly worked.
However, I have updated the service to use InstallUtil.exe and this auto update script no longer works... I assume it's something to do with the way InstallShield handles the service install vs how InstallUtil does it... but I can only make guesses as I don't fully understand what each is doing to the registry.
Since I can't just overwrite the files and restart the service with the InstallUtil method, I thought I'd write a batch script that runs sc.exe to stop the service, uninstall it entirely, write the new files, install the new service files, and then start it... unfortunately, I can't seem to get sc.exe to run from a windows service automatically because it requires admin permissions... I tried to force it to self-elevate to admin using this snippet, but it doesn't appear to work as a service (it works fine if I run it from command line not as a service)
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
Does anyone know how I can cause a windows service to self update? I can look into updating to a .NET Core Worker service if there is some method of self update in .NET Core that I'm unaware of... Any ideas are much appreciated... it really shouldn't be this hard to accomplish...
For reference, here is the batch script I am currently using (ignore odd variables and such as I am dynamically replacing some of them, it works great when launched manually, just doesn't work when the service tries to run it):
#echo off
setlocal enableextensions enabledelayedexpansion
::make sure to run whole script as admin (this restarts scripts as admin if not already in admin mode)
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
pushd %networkDirectory%
::stop running service
for /F "tokens=3 delims=: " %%H in ('sc query %serviceName% ^| findstr " STATE"') do (
if /I "%%H" NEQ "STOPPED" (
net stop %serviceName%
if errorlevel 1 goto :stop
)
::delete existing service after stopping
sc delete %serviceName%
)
:: install updated service files
set "releaseDir=%networkDirectory%\Release"
set "programFilesCopyDir=%ProgramFiles%\{_companyDirectory}\%serviceName%\Release"
:: copy service Release dir to local system program files
xcopy "%releaseDir%" "%programFilesCopyDir%" /S /Y /Q
::execute the install
pushd "%programFilesCopyDir%"
CALL %serviceName%.exe --install
::start service
sc start %serviceName%
For anyone else trying to accomplish this that stumbles on this... I ended up finding a solution. I use the same script posted in my question above, but I wrote code to set up a scheduled task with Windows Task Scheduler. The scheduled task runs the above script as a one time scheduled task. This works like a charm.
I used this NuGet package to write the Task Scheduler code I needed:
https://www.nuget.org/packages/TaskScheduler/2.8.20?_src=template
Sometimes there is a PC that doesn't have IIS. Either it disabled or either it not installed. In this case I need to enable it myself according to those steps.
I'm trying to create application that will check if IIS is enabled (installed), and if not it will enable (install) it.
I tried to install IIS using .msi files from here, but it asking me to follow those stpes before the installation.
I tried to use Advanced Installer but apparently it installing the IIS 8.0 Express but still it keeps the IIS disabled.
What I need to do to enable IIS programmatically? It is also acceptable if I'll need to run an IIS installation file to make it done (I didn't find the right one).
You can install IIS via the command line. The following command will install IIS on Windows 8 (you can edit this to add/remove certain features. It's just a command I've used in the past):
PkgMgr:
start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-NetFxExtensibility45;IIS-ASPNET45;IIS-NetFxExtensibility;IIS-ASPNET;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI
DISM:
START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DigestAuthentication /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HostableWebCore /FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect /FeatureName:IIS-HttpTracing /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-IISCertificateMappingAuthentication /FeatureName:IIS-IPSecurity /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-LegacyScripts /FeatureName:IIS-LegacySnapIn /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebDAV /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService
In C#, you can create a Process that executes this command like so:
string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
You tag your question with InstallShield so I mention that later versions of InstallShield have support for enabling windows features:
Enabling Windows Roles and Features During a Suite/Advanced UI Installation
That said, I don't typically like to do this because you are really be intrusive with the configuration of the PC. I prefer to author a check that the required features are installed and block if they aren't.
Another thought is that ASP.NET 5.0 now supports self hosting as have other technologies such as WCF in the past. It might make sense to simply ditch the need for IIS and kill the problem that way.
Regarding your experience with Advanced Installer. You ended up with IIS Express installed because you used our predefined support for prerequisites. You should have been using the predefined support to install Windows Feature Bundles.
Using this support you can easily select which OS feature should be enabled and also set custom conditions. On our YouTube channel you can find examples/tutorials:
in the following example you see exactly how IIS is configured for enabling
here is also a more generic video, with a walkthrough over the built-in support from Advanced Installer for enabling Windows Features
You can install IIS from command line. First you need to enable ASP.NET 3.5:
IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45
or 4.5:
IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45
After that you can install IIS8, basically like IIS7. Checkout the IIS7 instalation http://www.iis.net/learn/install/installing-iis-7/installing-iis-from-the-command-line
I'm trying to connect to a C# service. I can view the service in Windows Task Manager, but it does not appear in the "Available processes" List. I've tried running VS2012 as my normal user, as administrator, with "Show processes from all users" and Managed (v4.5, v4.0) code instead of the default. The service is built in Debug mode and then installed using an installer(Wix). On every demonstration of this, I've seen "Show Processes In All Sessions" but this is not shown in my Attach to process dialogue.
I managed to connect from a command line using "vsjitdebugger.exe -p 7012" but this wants to debug in a new instance, and should I use that new instance, I can't see any of the code.
Any advice would be really appreciated.
I have the following in a vbs file that i am trying to run from the command line:
strServerName = "ServerName"
strAppPoolName = "DefaultAppPool"
set objAppPools = GetObject("IIS://" & strServerName
& "/w3svc/AppPools/" & strAppPoolName & "")
objAppPools.Recycle()
And yet when I run the vbs from cmd line i get the following error:
Microsoft VBScript runtime error: ActiveX component can't create object: 'Get Object'_
I am running XP on my local machine, and the remote machine has IIS 7.
How can I get this to work?
I am not sure regarding the particular vb script but I would recommend using "appcmd" (http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe)
Add %windir%\system32\inetsrv to your path if it is not already
in a command prompt type: appcmd recycle apppool "apppool_name"
While not a vbs file command you could get vbs to execute this command line;
appcmd recycle apppool /apppool.name:string
The variable string is the name of the application pool that you want to recycle. For example, to recycle an application pool named Marketing, type the following at the command prompt, and then press ENTER:
appcmd recycle apppool /apppool.name:Marketing
Taken from technet
If it's too far away from what you want then my apologies.
Use powershell command to run it. Example:
Invoke-WMIMethod Recycle -Path "IIsApplicationPool.Name='W3SVC/APPPOOLS/apppoolname'" -Computer "WIN-Computername" -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy
Where apppoolname is your application pool name.
Where WIN-Computername is your remote/local server name
Use powershell to execute command remotely on the server:
Invoke-Command -ComputerName <YOUR_IIS_SERVER_NAME> -ScriptBlock { Restart-WebAppPool -Name <YOUR_APP_POOL_NAME> }
I just tried it from a Windows XP machine to Windows 2008R2 machine. It worked. So you are definitely on the right track.
If you are looking for an alternative way, try this from a command prompt. At least the error message will be a little more specific, when it doesn't work.
wmic /namespace:"\\root\MicrosoftIISv2" /node:"**serverName**" path IISApplicationPool where (name like '%**DefaultAppPool**%') call recycle
Have you got the IIS7 WMI Provider installed and enabled on the remote machine?
I think this doc covers most of what you need.
this covers pre req and how to browse the available management options...sure you'll be able to reset the app pool with a few tweaks...
I just stumbled upon this problem, and here's the fix:
There is a small windows tool called PsExec, which basically gives you command line remote access, and from there you can use apppool. You can just run this command from C#
psexec \\192.168.xx.xx %windir%\system32\inetsrv\appcmd recycle apppool /apppool.name:yourapppool
here's the tool: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
Following commands worked for me after trying everything !
cd %windir%\system32\inetsrv
appcmd.exe stop site /site.name:"test1.com"
appcmd.exe start site /site.name:"test1.com"
Obviously before these, you will run some ssh remote command as well
I have some trouble installing Management Studio 2008 Express through C#-Code.
The code looks like this:
using (Process MMSInstall = new Process())
{
var psi = new ProcessStartInfo(PathExe.FullName, "/qs /Features=SSMS /Action=Install");
MMSInstall.StartInfo = psi;
MMSInstall.Start();
MMSInstall.WaitForExit();
}
PathExe is a FileInfo-Instance.
But the installation always fails:
Exception type: Microsoft.SqlServer.Setup.Chainer.Workflow.NoopWorkflowException
Message:
No features were installed during the setup execution. The requested features may already be installed. Please review the summary.txt log for further details.
When installing via command prompt
C:\>SQLMANAGEMENTSTUDIO_X86_DEU.EXE /qs /Features=SSMS /Action=Install
everything works fine.
I looked through the logfiles (Detail.txt), and spottet a difference:
When running from the command prompt, 'Setting: MEDIALAYOUT' is set to 'Advanced' (pastebin.org/36222), when installing from my little C#-App it's set to 'Core' (pastebin.org/36221)
I tried to append /MEDIALAYOUT=Advanced to the ProcessStartInfo-Arguments in my code, but this options is ignored. I don't know what this parameter does, and I could not find any documentation about it.
Any ideas how to solve this or where to look for?
I am testing on Windows Vista Ultimate SP1
instead of calling the executable directly call %windir%\system32\cmd.exe
Cmd has a /C switch which allows you to pass in a command to run. So you'd pass in '/c "SQLMANAGEMENTSTUDIO_X86_DEU.EXE /qs /Features=SSMS /Action=Install"'
as a parameter.