Create IIS 6 application pool - command-line

Can someone let me know how (or point me to right direction) I can create an application pool and set an application to use the newly created pool using commandline? Application has already been added to IIS but need to create a new pool and use it for this new application.

This is what I gathered, in case anyone else is looking for the same thing:
rem // Creates a new application pool called MyAppPool
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS CREATE w3svc/AppPools/MyAppPool IIsApplicationPool
rem // if running under different user name and password
rem CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET w3svc/AppPools/MyAppPool/WamUserName "domain\username"
rem CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET w3svc/AppPools/MyAppPool/WamUserPass "pass"
rem CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET w3svc/AppPools/MyAppPool/AppPoolIdentityType 3
========================================
rem // create a new virtual directory (creates vdir "Test" and set it to D:\WebSites\MyWebSite
CSCRIPT %SystemRoot%\system32\iisvdir.vbs /Create W3SVC/1/ROOT Test D:\WebSites\MyWebSite
=================================
rem // assign MyAppPool to "Test" web site
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET W3SVC/1/ROOT/Test/AppPoolId MyAppPool

Related

How to Abort Informatica workflow if source file has only header row

I have a requirement wherein I am checking if source file which is in CSV format has only header rows i.e. 1 row only then I need to fail the informatica workflow. Informatica is installed in Windows server so only Command task is supported not Unix or bash.
I am using below code to count lines in source file using Command Task in workflow.
for /f "usebackq" %%b in (type $$outputfile ^| find "" /v /c)do (
echo line count is %%b> $$count_file.txt
)
)
Here $$outfile and $$count_file paths and filenames are picked from param files.
There is an ABORT() function that you can use in expression transformation.
Create a dummy column and put a sorter, aggregator right after the source qualifier. in the aggregator, get a count of all data and then join it back to the main flow. After joiner, put an expression transformation with below condition-
IIF( cnt_all > 1, NULL, ABORT( 'Only header exists in the input file! Session will be aborted.'))
Whole mapping should look like this --
SQ -- EXP(add dummy_col) -->SRT on dummy_col -->AGG on dummy_col, calculate Count(*)->|
|--------------------------------------------> JNR on dummy_col -->EXP (abort if count <=1) --> existing mapping logic...
EDIT :
From command task, you can call pmcmd abortworkflow when your condition satisfies. Normal syntax is below -
pmcmd abortworkflow -service service -user username -password password -f folder workflow

AWS Lambda deployment

I'm trying to deploy my lambdas (.NET Core 2.0) into AWS by using AWS CLI + TeamCity + Powershell script. I have some steps , including deploy step and applying new aliase number step.
While deploy step I don't get alias number (lambda version). A script returns me something like "function = ", but it should be like "result = 44 (or any other lambda version)".
Here's a script (mix of Powershell + AWS CLI commands).
FOR ( /F "tokens=* delims=" %%%A IN ('dotnet lambda deploy-function MyLambda --profile default --region my-server-region --configuration Release --function-publish true') DO ( set result=%%%A )){
FOR ( /F "tokens=1,2,3,4,5,6 delims= " %%%A IN ('echo %%%result%%%') DO ( set result=%%%F )){
#echo on
echo %env.MyLambdaVersion%
#echo off
echo "##teamcity[setParameter name='env.MyLambdaVersion' value='%%result%%']"
}
}
I actually don't know what I do wrong, actually this script was written before I started to work on this project. Any advice or any link will be helpfull, thanks :)
EDIT
I expect this kind of respinse, where i can get MyLambda version
Succesfull build scrinshot1: https://i.stack.imgur.com/bOIGr.jpg
But instead of it I'm getting this result.
Invalid response
EDIT 2
Output of the script in text format
Step 17/36: Deploying new version of Lambda "MyLambda" (Command Line) (3m:16s)
[13:27:03][Step 17/36] Starting: C:\BuildAgent\temp\agentTmp\custom_script1964828788270486366.cmd
[13:27:03][Step 17/36] in directory: C:\BuildAgent\work\3f3a1ea85ff2ff09
[13:30:10][Step 17/36]
[13:30:11][Step 17/36] C:\BuildAgent\work\3f3a1ea85ff2ff09\Proj\Lambda\Proj.Lambda.MyLambda>echo
[13:30:12][Step 17/36] ECHO is on.
[13:30:16][Step 17/36] "
[13:30:16][Step 17/36] ##teamcity[setParameter name='env.MyLambdaVersion' value='function: ']
[13:30:16][Step 17/36] "
[13:30:20][Step 17/36] Process exited with code 0

Azure Batch: Does StartTask run when the node is already joined to a pool

I have setup a azure batch which is a User Subscription type. Pool is already setup with 3 nodes which are in idle state. from my c# code I get the pool reference and run StartTask and do CommitAsync.
Does this caused the StartTask to run or will StartTask only be executed when the node tires to join the pool.
pool = batchClient.PoolOperations.GetPool(poolId);
pool.StartTask = new StartTask
{
CommandLine = "cmd /c (robocopy %AZ_BATCH_TASK_WORKING_DIR% %AZ_BATCH_NODE_SHARED_DIR%) ^& IF %ERRORLEVEL% LEQ 1 exit 0",
ResourceFiles = resourceFiles,
WaitForSuccess = true
};
When I run this code it does not seem to copy the required files to Node shared directory.
As documented, a Start Task runs when a node joins a pool, reboots or is reimaged.

Play framework 2.5 not loading application.prod.conf, only the default application.conf

I've run sbt clean stage and am trying to run my application in prod mode using the generated script. When running target\universal\stage\bin\app-name.bat . -Dconfig.resource=application.prod.conf it complains that the application secret is not set. After some troubleshooting I realised that it was still loading the default config filebecause after deleting target\universal\stage\conf\application.conf I get the following error:
Oops, cannot start the server.
Configuration error: Configuration error[application: application.conf: java.io.IOException: resource not found on classpath: application.conf, application.json: java.io.IOException: resource not found on classpath: application.json, application.properties: java.io.IOException: resource not found on classpath: application.properties]
I've tried refering to it with the full path using -Dconfig.file, with the same result. How do I get it to load the right config file, other than renaming it to application.conf?
Here is the full command contained in the .bat file, autogenerated by sbt:
#REM game-check-match launcher script
#REM
#REM Environment:
#REM JAVA_HOME - location of a JDK home dir (optional if java on path)
#REM CFG_OPTS - JVM options (optional)
#REM Configuration:
#REM GAME_CHECK_MATCH_config.txt found in the GAME_CHECK_MATCH_HOME.
#setlocal enabledelayedexpansion
#echo off
if "%GAME_CHECK_MATCH_HOME%"=="" set "GAME_CHECK_MATCH_HOME=%~dp0\\.."
set "APP_LIB_DIR=%GAME_CHECK_MATCH_HOME%\lib\"
rem Detect if we were double clicked, although theoretically A user could
rem manually run cmd /c
for %%x in (!cmdcmdline!) do if %%~x==/c set DOUBLECLICKED=1
rem FIRST we load the config file of extra options.
set "CFG_FILE=%GAME_CHECK_MATCH_HOME%\GAME_CHECK_MATCH_config.txt"
set CFG_OPTS=
if exist "%CFG_FILE%" (
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%CFG_FILE%") DO (
set DO_NOT_REUSE_ME=%%i
rem ZOMG (Part #2) WE use !! here to delay the expansion of
rem CFG_OPTS, otherwise it remains "" for this loop.
set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME!
)
)
rem We use the value of the JAVACMD environment variable if defined
set _JAVACMD=%JAVACMD%
if "%_JAVACMD%"=="" (
if not "%JAVA_HOME%"=="" (
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
)
)
if "%_JAVACMD%"=="" set _JAVACMD=java
rem Detect if this java is ok to use.
for /F %%j in ('"%_JAVACMD%" -version 2^>^&1') do (
if %%~j==java set JAVAINSTALLED=1
if %%~j==openjdk set JAVAINSTALLED=1
)
rem BAT has no logical or, so we do it OLD SCHOOL! Oppan Redmond Style
set JAVAOK=true
if not defined JAVAINSTALLED set JAVAOK=false
if "%JAVAOK%"=="false" (
echo.
echo A Java JDK is not installed or can't be found.
if not "%JAVA_HOME%"=="" (
echo JAVA_HOME = "%JAVA_HOME%"
)
echo.
echo Please go to
echo http://www.oracle.com/technetwork/java/javase/downloads/index.html
echo and download a valid Java JDK and install before running game-check-match.
echo.
echo If you think this message is in error, please check
echo your environment variables to see if "java.exe" and "javac.exe" are
echo available via JAVA_HOME or PATH.
echo.
if defined DOUBLECLICKED pause
exit /B 1
)
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
set _JAVA_OPTS=%JAVA_OPTS%
if "!_JAVA_OPTS!"=="" set _JAVA_OPTS=!CFG_OPTS!
rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments
rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPTS
set _JAVA_PARAMS=
set _APP_ARGS=
:param_loop
call set _PARAM1=%%1
set "_TEST_PARAM=%~1"
if ["!_PARAM1!"]==[""] goto param_afterloop
rem ignore arguments that do not start with '-'
if "%_TEST_PARAM:~0,1%"=="-" goto param_java_check
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
shift
goto param_loop
:param_java_check
if "!_TEST_PARAM:~0,2!"=="-J" (
rem strip -J prefix
set _JAVA_PARAMS=!_JAVA_PARAMS! !_TEST_PARAM:~2!
shift
goto param_loop
)
if "!_TEST_PARAM:~0,2!"=="-D" (
rem test if this was double-quoted property "-Dprop=42"
for /F "delims== tokens=1,*" %%G in ("!_TEST_PARAM!") DO (
if not ["%%H"] == [""] (
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
) else if [%2] neq [] (
rem it was a normal property: -Dprop=42 or -Drop="42"
call set _PARAM1=%%1=%%2
set _JAVA_PARAMS=!_JAVA_PARAMS! !_PARAM1!
shift
)
)
) else (
if "!_TEST_PARAM!"=="-main" (
call set CUSTOM_MAIN_CLASS=%%2
shift
) else (
set _APP_ARGS=!_APP_ARGS! !_PARAM1!
)
)
shift
goto param_loop
:param_afterloop
set _JAVA_OPTS=!_JAVA_OPTS! !_JAVA_PARAMS!
:run
set "APP_CLASSPATH="
set "APP_MAIN_CLASS=-jar %APP_LIB_DIR%\game-check-match.game-check-match-0.1.0-launcher.jar"
if defined CUSTOM_MAIN_CLASS (
set MAIN_CLASS=!CUSTOM_MAIN_CLASS!
) else (
set MAIN_CLASS=!APP_MAIN_CLASS!
)
rem Call the application and pass all arguments unchanged.
"%_JAVACMD%" !_JAVA_OPTS! !GAME_CHECK_MATCH_OPTS! -cp "%APP_CLASSPATH%" %MAIN_CLASS% !_APP_ARGS!
#endlocal
:end
exit /B %ERRORLEVEL%

Capture the date into a batch file variable

I'm writing a batch file to copy some data, the issue I have is, I want to capture the date in a variable so that I can use it as the file name. I would like it in the format of dd-mm-yyyy.
I found this example here, but I was unable to get it into the format I need.
this solution is independent of locale settings:
for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
It will give you (independent of locale settings!):
20130802203023.304000+120
( YYYYMMDDhhmmss.<fraction>+/-<timedifference to UTC> )
from here, it is easy:
set mydate=%datetime:~6,2%-%datetime:~4,2%-%datetime:~0,4%
echo %mydate%
Solution
set yy=%date:~-4%
set mm=%date:~-7,2%
set dd=%date:~-10,2%
set newdate=%dd%%mm%%yy%
echo %newdate%
:date
set dateyear=%date:~-4%
if %date:~-7,-5%==01 set datemonth=January
if %date:~-7,-5%==02 set datemonth=February
if %date:~-7,-5%==03 set datemonth=march
if %date:~-7,-5%==04 set datemonth=April
if %date:~-7,-5%==05 set datemonth=may
if %date:~-7,-5%==06 set datemonth=June
if %date:~-7,-5%==07 set datemonth=July
if %date:~-7,-5%==08 set datemonth=August
if %date:~-7,-5%==09 set datemonth=September
if %date:~-7,-5%==10 set datemonth=October
if %date:~-7,-5%==11 set datemonth=November
if %date:~-7,-5%==12 set datemonth=December
set dateday=%date:~-10,-8%
echo It is %dateday% %datemonth% %dateyear%, sir.
exit /B 0
:xpdate
echo It is %date%, sir.
%speech% "It is %date%, sir."
exit /B 0
:w7dat
if %time:~0,-9% GTR 12 (set /a timehour=%time:~0,-9%-12) else set timehour=%time:~0,-9%
if %time:~3,1%==0 (set timeminute=%time:~4,1%) else set timeminute=%time:~3,2%
set dateyear=%date:~-4%
if %date:~-7,-5%==01 set datemonth=January
if %date:~-7,-5%==02 set datemonth=February
if %date:~-7,-5%==03 set datemonth=march
if %date:~-7,-5%==04 set datemonth=April
if %date:~-7,-5%==05 set datemonth=may
if %date:~-7,-5%==06 set datemonth=June
if %date:~-7,-5%==07 set datemonth=July
if %date:~-7,-5%==08 set datemonth=August
if %date:~-7,-5%==09 set datemonth=September
if %date:~-7,-5%==10 set datemonth=October
if %date:~-7,-5%==11 set datemonth=November
if %date:~-7,-5%==12 set datemonth=December
set dateday=%date:~-10,-8%
echo It is currently %timeminute% minutes past %timehour% on %dateday% %datemonth% %dateyear%, sir.
exit /B 0
This is what i use in my batch AI just change the :date :w7dat and all those to what you need
Here is a solution using PowerShell, which is pre-installed on nearly all versions of Windows and is far more powerful than batch.
PowerShell code
Get-Date -Format 'yyyy-MM-dd'
Calling from a batch file
for /f %%a in ('powershell -nop -c "Get-Date -Format 'yyyy-MM-dd'"') do set newdate=%%a