1

We are working on automating the deployment of some IIS applications. I've used cscript.exe inside a windows batch file to create the web app and such. There are however a few settings currently done by hand that I need to automate. Namely, if you look at the properties of an app, under Directory Structure -> Authentication and access control -> Edit, I need to uncheck Enable anonymous access and check Integrated Windows authentication.

Is there an easy way to do this from a windows batch file?

EDIT: I should clarify this is IIS 6.0, so appcmd is not available.

4
  • You might look into using Windows PowerShell for this type of task in the future. Although the syntax is clunky, it allows access to .NET classes, etc and is significantly more powerful than vbscript or batch files. Commented Dec 7, 2009 at 18:56
  • What exactly do you do in the script you run by cscript.exe. Do you create the site in this script? Or do you use IIsWeb.vbs in the batch file? Commented Dec 9, 2009 at 0:19
  • I've updated my answer with a sample cscript snippet. Commented Dec 9, 2009 at 0:33
  • I basically copy the web site tree under Inetpub/wwwroot and then use: "" cscript.exe %systemroot%\system32\iisweb.vbs /create c:\inetpub\wwwroot "%1" /b %2 "" where %1 and %2 are some vars for the app name. If I then go into IIS Manager, under Web Sites, I can see the site and its identifier (under the Default Web Site and Sharepoint Admin) Commented Dec 9, 2009 at 13:56

4 Answers 4

2

hope this helpes:

http://forums.iis.net/t/1159665.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

I guess I would ask the same question I asked of Kev. This command from the link works as advertised: adsutil.vbs set w3svc/1/root/Authflags 4 However I want to run this command as part of the installation of a new app. The app as installed currently has an Identifier of 208223887, so I would want: adsutil.vbs set w3svc/208223887/root/Authflags 4 but I don't know that value until the app is installed. Is there any way to get this as a variable after the install step so I can substitute it into this command further down in my script?
1

I answered a very similar question a wee while back. The example uses the asdutil.vbs tool which you can call from your batch file:

Setting NTAuthenticationProviders at an Application level in IIS 6 (Stack Overflow)

Updated:

Because you've already got a CScript script to create the website, you can just set the AuthFlags in the script:

'' Some values just as an example
iisNumber = 668
ipAddress = "172.16.3.200"
hostName = "myserver.com"
wwwfolder = "c:\mysites\www"


Dim serverBindings(1)
serverBindings(0) = ipAddress & ":80:www." & hostName
serverBindings(1) = ipAddress & ":80:" & hostName


'' Create server
Set w3svc = GetObject("IIS://localhost/w3svc")
Set newWebServer = w3svc.Create("IIsWebServer", iisNumber)
newWebServer.ServerBindings = serverBindings
newWebServer.ServerComment = "Server is: " & hostName
newWebServer.SetInfo

'' Create /root app
Set rootApp = newWebServer.Create("IIsWebVirtualDir", "ROOT")
rootApp.Path = wwwFolder
rootApp.AccessRead = true
rootApp.AccessScript = true
rootApp.AppCreate(True)
rootApp.AuthFlags = 4 '' <== Set AuthFlags here
rootApp.SetInfo

1 Comment

Very useful, but one question, the script you provided works on the defaults web app (1) as you pointed out. How do I know from a programmatic standpoint, the Application ID, for an app other than the default app? I know its name, but windows generates the ID.
1

See Configure Windows Authentication (IIS 7):

appcmd set config /section:windowsAuthentication /enabled:true | false

For IIS 6 probably WMI is the alternative:

Comments

0
Dim sSitePath = "1" 'Set the site ID here
Set oSite =  GetObject("IIS://localhost/" & sSitePath & "/root")

Select Case oSite.AuthFlags
  Case 1
    Wscript.Echo "Anonymous"
  Case 2
    Wscript.Echo "Basic"
  Case 4
    Wscript.Echo "NTLM"
  Case 6
    Wscript.Echo "MD5"
  Case 64
    Wscript.Echo "Passport"
End Select

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.