Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use AppCMD to test and see if a website exists in IIS7 using the Site's Name?

Tags:

appcmd

I would like to add new bindings to a site using appcmd but I need to see if it exists first. How can I do so using AppCMD?

Much appreciated!

like image 735
Julian Dormon Avatar asked Apr 06 '13 20:04

Julian Dormon


1 Answers

You can create a batch file with the following code :

@ECHO OFF

SET appcmd=CALL %WINDIR%\system32\inetsrv\appcmd

%appcmd% list site /name:"Default Web Site"
IF "%ERRORLEVEL%" EQU "0" (
    ECHO EXISTS
    REM Add your bindings here
) ELSE (
    ECHO NOT EXISTS
)
like image 120
Eric Bonnot Avatar answered Sep 21 '22 06:09

Eric Bonnot