Sqlserver2008+IIS7.5 自动安装恢复及发部WEB

本文意在方便的部署一个WEB程序,故学写一个SHELL(俗称一下)
注:本次实验为 WINDOWS SERVER2008R2+Sqlserver2008(developer)+IIS7.5+ASP.NET
有啥米问题QQ:285979593留言哒

@echo off
set current_path=%~dp0
set hostname=WIN-S43U30SI4GQ
set INSTALLSQLDATADIR=c:\MSSQL2008
set INSTANCENAME=fkfj
set PASSWORD=IBM-Password2012
set restoredbname=dayunoatarget
set disk=%~dp0oatarget.bak
REM --------------------------------IIS变量
set sitename=dayun
set siteport=80
set sitephysicalpath=c:\oa
:init
mkdir %INSTALLSQLDATADIR%
mkdir %sitephysicalpath%
if exist c:\setup.txt (goto setup) else goto check


:setup
for /f  %%i  in (c:\setup.txt) do (ECHO %%i
if "%%i" == "STEP1" (goto STEP1)
if "%%i" == "STEP2" (goto STEP2)
if "%%i" == "STEP3" (goto STEP3)
if "%%i" == "STEP4" (goto STEP4)
if "%%i" == "STEP5" (goto STEP5)


)
goto exit
REM ------------------------------------------------------NET组件安装
:STEP1
echo STEP2> c:\setup.txt
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v autoinstall /d "%current_path%auto_install.bat" /f


ServerManagerCmd -install NET-Framework -allSubFeatures
Setup.exe /QS
shutdown -r -t 0
goto exit


REM ------------------------------------------------------数据库安装
:STEP2
echo STEP3>c:\setup.txt


Setup.exe /QS /ACTION=Install /SkipRules=VSShellInstalledRule /IAcceptSQLServerLicenseTerms="True" /FEATURES=SQLEngine,IS,SSMS /INSTANCENAME=%INSTANCENAME% /INSTALLSQLDATADIR="%INSTALLSQLDATADIR%" /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /SAPWD="IBM-Yunsoft2012" /SQLSYSADMINACCOUNTS="%hostname%\ADMINISTRATOR" /AGTSVCACCOUNT="NT AUTHORITY\SYSTEM" 
ping 127.1 -n 10 >nul 2>nul
shutdown -r -t 0
goto exit


REM ------------------------------------------------------数据库恢复
:STEP3
echo STEP4>c:\setup.txt 
ping 127.1 -n 20 >nul 2>nul
osql -E -S .\%INSTANCENAME% -Q "restore database %restoredbname% from disk = '%disk%' with move 'UCMLOASESTarget' to '%INSTALLSQLDATADIR%\MSSQL10_50.%INSTANCENAME%\MSSQL\DATA\UCMLOAEnv_090527.mdf',move 'UCMLOASESTarget_log' to '%INSTALLSQLDATADIR%\MSSQL10_50.%INSTANCENAME%\MSSQL\DATA\UCMLOAEnv_090527_log.ldf'"


pkgmgr /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
ping 127.1 -n 20 >nul 2>nul
shutdown -r -t 0


goto exit


REM ------------------------------------------------------开启数据库SA权限及IIS安装
:STEP4
echo STEP5>c:\setup.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.FKFJ\MSSQLServer /v LoginMode /t REG_DWORD /d 2 /f
ping 127.1 -n 20 >nul 2>nul
osql -E -S .\fkfj -Q "ALTER LOGIN sa WITH PASSWORD ='%PASSWORD%'"
osql -E -S .\fkfj -Q "ALTER LOGIN sa ENABLE"
net stop mssql$fkfj
net start mssql$fkfj


pkgmgr /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
shutdown -r -t 0
goto exit


REM ------------------------------------------------------拷贝文件及IIS发布
:STEP5
echo FINISH>c:\setup.txt
robocopy %current_path%BPObject %sitephysicalpath% /E
C:\Windows\System32\inetsrv\appcmd.exe add site /name:"%sitename%" /bindings:http://localhost:%siteport% /physicalpath:%sitephysicalpath%
C:\Windows\System32\inetsrv\appcmd.exe set apppool /apppool.name:DefaultAppPool /enable32BitAppOnWin64:true


net start aspnet_state
goto exit


REM ------------------------------------------------------
:check
echo 配制文件不存在
echo STEP1>c:\setup.txt
goto init


REM ------------------------------------------------------
:exit


 
 

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值