The command line script below allows you to create a Virtual Directory from an existing physical directory and set up an application pool. In this case the application pool will be running under a domain service account.
To use an identity of Network Service then replace
/processModel.identityType:SpecificUser ...
with
/processModel.identityType:NetworkUser
@echo OFF
IF "%1"=="" GOTO Syntax
IF "%2"=="" GOTO Syntax
IF "%3"=="" GOTO Syntax
IF "%4"=="" GOTO Syntax
set VDIRNAME=%1
set PHYPATH=%2
set USERNAME=%3
set PASSWORD=%4
REM Create Application Pool
%systemroot%\system32\inetsrv\APPCMD add apppool /name:%VDIRNAME%AppPool
%systemroot%\system32\inetsrv\APPCMD set apppool "%VDIRNAME%AppPool" /managedRuntimeVersion:v4.0
%systemroot%\system32\inetsrv\APPCMD set apppool "%VDIRNAME%AppPool" /managedpipelineMode:Classic
%systemroot%\system32\inetsrv\APPCMD set apppool "%VDIRNAME%AppPool" /processModel.identityType:SpecificUser /processModel.userName:%USERNAME% /processModel.password:%PASSWORD%
REM Add Virtual Directory
%systemroot%\system32\inetsrv\APPCMD add app /site.name:"Default Web Site" /path:/%VDIRNAME% /physicalpath:"%PHYPATH%"
%systemroot%\system32\inetsrv\APPCMD set app "Default Web Site/%VDIRNAME%" /applicationpool:%VDIRNAME%AppPool
:SYNTAX
ECHO.
ECHO VDir Name and Physical Path Required
ECHO.
ECHO CreateVDir.CMD VDirName C:\PhysPath Domain\UserName Password
ECHO example CreateVDir TEST c:\inetpub\wwwroot\test buildx\btsuser Password1
1 comment:
You write this:
IF "%1"=="" GOTO Syntax
IF "%2"=="" GOTO Syntax
IF "%3"=="" GOTO Syntax
IF "%4"=="" GOTO Syntax
But all you need is this:
IF "%4"=="" GOTO Syntax
Because when %4 exists, you know that every previous parameter also exists.
Post a Comment