zoukankan      html  css  js  c++  java
  • IIS命令行静默安装脚本-python

    #coding=utf8
    import platform
    from subprocess import Popen,PIPE,STDOUT
    import sys,os
    
    
    def run_cmd(cmd, cwd=None, env=None, run_as=None):
        if not sys.platform.startswith('win') and run_as and run_as != 'root':
            cmd = 'su - {} -c "{}"'.format(run_as, cmd)
        p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE, cwd=cwd, env=env)
        stdout, _ = p.communicate()
        return p.returncode, stdout.strip()
    
    
    if platform.uname()[0].lower() != 'windows':
        print '只支持windows系统'
        sys.exit(1)
    
    
    
    if platform.uname()[2] == '7' or '2008server' in platform.uname()[2].lower():
        cmd = 'start /w pkgmgr /quiet /norestart /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-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;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'
    elif platform.uname()[2] == '8'  or '2012server' in platform.uname()[2].lower():
        cmd = "start /w pkgmgr /quiet /norestart /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;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"
    else:
        print '无法判断系统详细版本'
        print platform.uname()
        sys.exit(1)
    
    
    code, res = run_cmd(cmd)
    if code:
        print res
        sys.exit(1)
    
    print '服务安装成功'
    

      装完后可能需要手工启动服务

    刚装完window 7系统 和 IIS,可程序始终跑不起来,报IIS未完整安装错误
    进行如下安装果断跑起来了(需用administrator 帐号进系统):
    1.打开运行输入 cmd
    2.输入 cd C:WindowsMicrosoft.NETFrameworkv4.0.30319
    3.输入 aspnet_regiis.exe -i

    IIS Admin Service(WAS)iis管理服务
    是IIS6中的,用于将来自http.sys的请求转发给应用程序池

    在IIS7/IIS8中,没有了IIS Admin Service,对应的是Windows Activation Service(WAS)。

    由于关闭时关联服务W3SVC也会被关闭,所以也需要net start w3svc

  • 相关阅读:
    java笔记使用线程池优化多线程编程
    java笔记查看和修改线程名称
    java笔记查看和修改线程的优先级
    java笔记策略模式和简单工厂模式
    java笔记用ThreadLocal管理线程,Callable<V>接口实现有返回值的线程
    java笔记枚举总结与详解
    java笔记关于克隆技术
    java笔记反射机制之基础总结与详解
    java笔记使用事件分配线程更新Swing控件
    java笔记关于int和byte[]的转换
  • 原文地址:https://www.cnblogs.com/slqt/p/10562880.html
Copyright © 2011-2022 走看看