0

I have a legacy website creation script written in VBScript which configures a number of virtual directories on the default web site using WMI. I now have a requirement to configure the virtual directories for ASP.NET and can't for the life of me figure out how to script this configuration.

I'm trying to set a number of parameters that are accessed via the 'ASP.NET' tab of the virtual directory properties. In particular, I need to add some application settings (key, value pairs) and set the globalization response encoding.

Nothing I've seen anywhere on the web has got me anywhere close to being able to do this in WMI/VBScript. Can anyone put me out of my misery?

Thanks, Al.

Al Henderson
  • 307
  • 1
  • 3
  • 11

3 Answers3

1

Providing you have .NET 2.0 installed on the system, for IIS5.1/IIS6 you could do the following.
1. Query for ASP.NET if it is installed:
cscript "%windir%\system32\iisext.vbs" /ListExt
2. If 'ASP.NET v1.1.4322' or 'ASP.NET v2.0.50727' doesn't exist, then install ASP.NET (eg for v2.0) setting it to be "allowed":
Enable ASP.NET: cscript "%windir%\system32\iisext.vbs" /AddFile "%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" 1 "ASP.NET v2.0.50727" 1 "ASP.NET v2.0.50727"

Disable ASP.NET: cscript "%windir%\system32\iisext.vbs" /AddFile "%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" 0 "ASP.NET v2.0.50727" 1 "ASP.NET v2.0.50727"
3. Create an IIS object: Set oIIS = GetObject("IIS://localhost/W3SVC/1/Root")
4. Create a virtual directory object: Set oIIS.Create("IISWebVirtualDir",<PackageName>)
5. Set some virtual directory settings: refer too http://msdn.microsoft.com/en-au/library/ms524579(v=vs.90).aspx & http://msdn.microsoft.com/en-au/library/ms525644(v=vs.90).aspx

Also take a look at this previous Stackoverflow post:
Can I automate creating a .NET web application / virtual directory in IIS 5?

Hope this helps ;)

Community
  • 1
  • 1
MacG
  • 271
  • 2
  • 4
0

Could you move from VB into a command line script instead and launch that from VB?

How to create virtual directory from command line in IIS7: http://technet.microsoft.com/en-us/library/cc771804%28v=ws.10%29.aspx

IIS6:

http://ayesamson.com/2010/06/14/create-virtual-directory-in-iis-6-0-via-command-line/

Andrew Walters
  • 4,763
  • 6
  • 35
  • 49
  • That's a possibility, I guess, although I was hoping to do it natively from within vbscript. I'll have a look into the techniques in that link - thanks Andrew. – Al Henderson Sep 09 '12 at 07:02
0

So, having not come across any way of programmatically setting the ASP.NET stuff in IIS6, I ended up just writing out the appropriate sections in the web.config file. For my limited purposes, this is OK as IIS6 does not usually create a web.config for my website so I don't have to worry about parsing the existing file and putting new stuff in the right order.

Not ideal (not even close!), but it gets me going and since the future is IIS7+ where I can do this kind of stuff, I'm not going to lose any more sleep over it :-)

Thanks for all input.

Al.

Al Henderson
  • 307
  • 1
  • 3
  • 11