:: Make sure to set the variables in the other batch files :: Variable values are case sensitive :: Do not enclose string variables in inverted commas @ECHO OFF :: ****** SET THE FOLLOWING TWO FOLDER LOCATIONS SET deploymentHistoryFolder=C:\Deployment\History :: ** Project Name should be passed in @ECHO Project Name= %ProjectName% :: **Server is the name of the IIS Application to deploy to (e.g. MyWebServer or localhost) @ECHO Server=%Server% :: **Target is the DEV, QA or LIVE. Which server we are deploying too. @ECHO Target=%Target% :: ** Base Path is the folder that contains the batch files and parameters files :: use ~dp0 to get the path of the current file we. %CD% returns the current dos prompt folder, which may be different. SET BasePath=%~dp0 :: ** The PackageFolder is the folder that contains the latest package SET PackageFolder=%BasePath%_PublishedWebsites\%ProjectName%_Package @ECHO PackageFolder=%PackageFolder% :: **Package Path is the full path to the package SET PackagePath=%PackageFolder%\%ProjectName%.zip @ECHO PackagePath=%PackagePath% :: ** The ParamsFileName stores the location of the param file SET ParamsFileName=%BasePath%%ConfigFileName% @ECHO Params from %ParamsFileName% @ECHO @ECHO Deploying %PackagePath% using %ConfigFileName% @ECHO ::DETERMINE WHETHER TO DELETE ALL FILES ON THE TARGET if NOT defined DoNotDelete (set DoNotDelete=true) IF %DoNotDelete%==true ( SET DoNotDeleteParams=-enableRule:DoNotDeleteRule @ECHO Set Do Not Delete Rule ) ::SET THE AUTHENTICATION TYPE if NOT defined UseBasicAuth (set UseBasicAuth=true) IF %UseBasicAuth%==true ( SET AuthParams=/A:Basic @ECHO Authentication - Use Basic ) else ( SET AuthParams=/A:NTLM @ECHO Authentication - Use NTLM ) ::Set the default username and password to use, if one hasnt been passed in if NOT defined DeploymentUser ( SET UserNameForTarget=WEB/WebAdmin SET PasswordForTarget=webadminpassword @ECHO Set UserNameForTarget and PasswordForTarget - Default ) ::Override the defult, for particular servers if %Server%==192.168.125.7 ( SET UserNameForTarget=WEB02/admin SET PasswordForTarget=HereIsMyPassword @ECHO Set UserNameForTarget and PasswordForTarget - WEB02 ) if %Server%==VM-SynWeb ( SET UserNameForTarget=domainAdmin/Administrator SET PasswordForTarget=domainadminpassword @ECHO Set UserNameForTarget and PasswordForTarget - Vm-SynWeb ) ::SET THE USERNAME AND PASSWORDS FOR DEPLOYMENT ::Set the username and password (Priority: 1. Passed in, 2. By Target, 3. Default) if defined DeploymentUser ( SET AuthParams=%AuthParams% /U:%DeploymentUser% @ECHO Apply DeploymentUser %DeploymentUser% ) else ( if defined UserNameForTarget ( SET AuthParams=%AuthParams% /U:%UserNameForTarget% @ECHO Apply UserNameForTarget %UserNameForTarget% ) else (@ECHO Apply No UserName) ) if defined Password ( SET AuthParams=%AuthParams% /P:%Password% @ECHO Apply Defined Password ) else ( if defined PasswordForTarget ( SET AuthParams=%AuthParams% /P:%PasswordForTarget% @ECHO Apply PasswordForTarget ) ) @ECHO Additional Params: %AdditionalParams%% ::call %ProjectName%.deploy.cmd /Y /M:https://localhost:8172/MSDeploy.axd /U:Domain/Administrator /P:Pass@word1 /A:Basic -allowUntrusted -setParamFile:%ParamsFileName% -debug -verbose CALL %PackageFolder%/%ProjectName%.deploy.cmd /Y /M:https://%Server%:8172/MSDeploy.axd %AuthParams% -allowUntrusted -setParamFile:%ParamsFileName% %DoNotDeleteParams% %AdditionalParams% if NOT ERRORLEVEL 0 GOTO :EXITFAILLABEL :: Here is where we can perform additional operations if required. if ERRORLEVEL 0 GOTO :EXITLOGOK :EXITFAILLABEL @ECHO FAIL!!, %DATE% %TIME%, %USERDOMAIN%\%USERNAME%, %Server%, %ConfigFileName%, %ProjectName%, %BasePath% >> %deploymentHistoryFolder%\history.txt GOTO :EXITLABEL :EXITLOGOK @ECHO ok, %DATE% %TIME%, %USERDOMAIN%\%USERNAME%, %Server%, %ConfigFileName%, %ProjectName%, %BasePath% >> %deploymentHistoryFolder%\history.txt :EXITLABEL @ECHO DONE pause