2013-04-06 35 views

Trả lời

12

Bạn có thể tạo một tập tin batch với đoạn mã sau:

@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 
) 
+0

này hoạt động cho nút cấp cao nhất, nhưng những gì về một trang web nằm dưới "Default Trang mạng"? – Paul

0

Đây là cách PowerShell:

$exists = (&$appcmd list apppool /name:'MyApplicationPool') -ne $null 

if ($exists -eq $false) 
{ 
    Write-Host 'App Pool does not exist' 
} 
else 
{ 
    Write-Host 'App Pool exists' 
} 
Các vấn đề liên quan