How do you configure IIS5 advanced settings from command line? - iis

I am trying to automate some of the build process for my asp.net apps by creating the virtual directories it needs and setting all their settings in a batch file. So far I have been able to figure out how to create virtual directories, but how to do you configure them beyond that?
For example I need to be able to set them as an application, set the default document, change framework version, turn on integrated authentication, etc. Does anyone know of any scripts that can do all this without a third party utility? Does the adsutil.vbs admin script do any of this?

Thanks, that documentation helped a lot. I wanted to post the script I ended up with. It generates the virtual directory, sets access settings, makes it an application, sets its isoloation level, sets default document, sets authentication, and even sets the framework version. Its everything I have been looking for. It does it all with the admin scripts that come with IIS5.
mkwebdir -c LocalHost -w "Default Web Site" -v "myvirdirectory","C:\Website Path\..."
adsutil APPCREATEINPROC w3svc/1/root/myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AppFriendlyName myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AccessScript True
adsutil SET w3svc/1/root/myvirdirectory/AppIsolated 2
adsutil SET w3svc/1/root/myvirdirectory/AuthAnonymous True
adsutil SET w3svc/1/root/myvirdirectory/AuthNTLM False
adsutil SET w3svc/1/root/myvirdirectory/AuthBasic False
adsutil SET w3svc/1/root/myvirdirectory/DefaultDoc index.aspx
adsutil SET w3svc/1/root/myvirdirectory/EnableDefaultDoc True
%windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s w3svc/1/root/myvirdirectory

Look at http://msdn.microsoft.com/en-us/library/ms524830%28VS.90%29.aspx and http://msdn.microsoft.com/en-us/library/ms524579%28VS.90%29.aspx.

Related

Tor hidden service - programmatically add a service without using the torrc file

I know how to setup a hidden service in the torrc file and it works, I am very new to this. if anyone could point me in the right direction I don't mind the hard work to learn something.
To programmatically create a hidden service, send the ADD_ONION command to the Tor controller. This requires that ControlPort is set in the torrc file and that you have set up some form of authentication.
For details, see ADD_ONION from Section 3 (Commands) of the Tor control-spec document.
The Python stem library supports this and has examples: https://stem.torproject.org/tutorials/over_the_river.html#running-a-hidden-service
In PHP the torutils library has an example here: https://github.com/dapphp/TorUtils/blob/master/examples/tc_CreateHiddenService.php

How to setup default document for a IIS website from command prompt?

I want to set default document for a IIS website from command prompt.
May I know how to setup this..
Thanks,
Mahesh
You can use appcmd.exe:
appcmd set config /section:defaultDocument /enabled:true|false
Check appcmd help at MSDN (or here) for more information.
http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe

Run a vbscript under an IIS application

I have a vbs file that runs fine and I want to run it under an IIS7 application name. Can this be done? If so, how?
thanks
You could look under "Handler Mappings" in IIS and add one similar to ASP which is how I used to run VBScript on the server side years ago. This does imply that the file is on a web server and you are OK with HTML output of the result.
Just for fun, I was wondering how to do this. I found an article on the Microsoft support site which told me this was possible at one time. As of IIS 7.5 this is even easier than the article suggests. You simply need to create the mapping in IIS:
Steps
Go to the IIS configuration and select the site you'd like to use
VBS files with.
Go to the Handler Mappings configuration for that site.
Click Add Script Map... on the right hand side.
Set the Request Path to *.vbs
Set the Executable to "C:\Windows\System32\cscript.exe" //NOLOGO %s %s
Set the Name to something you'll remember if you need to.
Restart IIS (possibly optional but I did this)
Then, test it with a script such as the following:
WScript.Echo "Content-Type: text/html"
WScript.Echo
WScript.Echo "If you see this, it worked."
Save it as test.vbs in your site and go to the URL to see the results. Every script used this way must begin output with the first two lines of this script or IIS will not use it.
Note: I also have the CGI (from the Windows installation disk) and Fast-CGI (from the Windows download center) modules installed. I'm not sure whether either of these are actually needed though.

How to find relative path to C:\Inetpub\AdminScripts\ADSUTIL.VBS?

IIS 6 and older ships with a utility script called ADSUTIL.VBS:
Adsutil.vbs is an IIS administration
utility that uses Microsoft Visual
Basic Scripting Edition (VBScript)
with Active Directory Service
Interfaces (ADSI) to manipulate the
IIS configuration. This script should
be run using CScript, which is
installed with Windows Script Host.
In other words, this tool lets you change IIS metabase settings programmatically, from the command line.
I would like to call this tool from an InstallShield project in order to make some configuration changes to IIS. I am curious if it either legal to re-distribute the script (there is no legal wording inside the source for it) or to simply launch the command via:
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs
and hope that the script exists on disk in that location.
So my question is - will it always exist in that path above, even if some other websites (inetpub roots) on the machine are located on a non-system drive? It seems all MSDN and other Microsoft KB articles that refer to the ADSUTIL tool do so by using the %SYSTEMDRIVE% path above.
I see that at least one other attempt to deal with this by distributing both cscript.exe and adsutil.vbs with their InstallShield projects.
Perhaps there is a registry key or other method to obtain the location of the Inetpub\AdminScripts path?
Maybe I should just write a C# application that changes the value or my own VBScript and distribute with my own little app instead?
I ran into a similar issue recently and decided to just rework a small bit of vbscript to use in a custom action in an msi installer. It can take a bit to figure out the core of how adsutil.vbs does things, but it is deently well writen. For example, i needed to switch an application pool to Classic instead of Integrated mode and explicitly set it to run in 32-bit mode when on 64-bit windows, in distilled form this resulted in this:
Option Explicit
Dim IIsObject
Set IIsObject = GetObject("IIS://LocalHost/W3SVC/AppPools/TestPool")
IIsObject.Put "ManagedPipelineMode", 1
IIsObject.Setinfo
IIsObject.Put "Enable32BitAppOnWin64", CBool("True")
IIsObject.Setinfo
I worked in JShumaker's answer to solve the problem. The best route seems to be the following InstallScript function that I call to run a batch script:
prototype SetIISValues();
function SetIISValues()
string szProgram, szCmd;
begin
szProgram = TARGETDIR + "SetIISValues.bat";
szCmd = "";
LaunchAppAndWait (szProgram, szCmd, LAAW_OPTION_WAIT);
end;
The batch script calls this:
#echo off
cscript.exe SetIISValues.vbs
And the VBScript looks like this:
Option Explicit
Dim IIsObject
Set IIsObject = GetObject("IIS://localhost/w3svc/1")
IIsObject.Put "Name", "Value"
IIsObject.Setinfo
Doing it this way relieves the need to use ADSUTIL.VBS as part of the installation - the (relative) path to it is irrelevant if you don't need to use it.

How to Set User-Developed Web Browser as the Default Browser?

I am developing a web browser in c#.. i need to give option to the user for my web browser as set to Default browser??? how is it possible
On Windows check out this Registry key:
HKEY_CLASSES_ROOT\HTTP\shell\open\command
There's also HTTPS too. You'd ideally want to check this is set to your application and if not then ask to set it.
You need to set the registry key HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default). Or HKEY_LOCAL_MACHINE if you want it to affect the entire machine (in which case you may need to set the HKCU version too or it will override).

Resources