Friday, September 21, 2012

IIS 5.1 Configuration Using VBScript with Command Line


IIS 5.1 Configuration Guide
Q). How to Creating Virtual Directory Using VBScript with Command line?
A). You can use mkwebdir.vbs at Inetpub\AdminScripts directory.

 mkwebdir [--computer|-c COMPUTER1, COMPUTER2, COMPUTER3]
         <--website|-w WEBSITE>
         <--virtualdir|-v NAME1,PATH1,NAME2,PATH2,...>
         [--help|-?]
cscript mkwebdir.vbs -c localhost -w “Default Web Site” –v “Virtual Dir1,c:\inetpub\wwwroot\dir1,Virtual Dir2,c:\inetpub\wwwroot\dir2”  (OR)
cscript mkwebdir.vbs -c localhost -w 1  –v “Virtual Dir1,c:\inetpub\wwwroot\dir1,Virtual Dir2,c:\inetpub\wwwroot\dir2”  (OR)
You can use adsutil.vbs at Inetpub\AdminScripts directory.
adsutil.vbs create  w3svc/1/root/vdName "IISWebVirtualDir"
adsutil.vbs  set  w3svc/1/root/vdName/path "C:\MyFolder"
The first command create a virtual directory under w3svc/1/root. The w3svc/1/root is a IIS metabase path. 1 here is the default website's identifier. The second command specify the virtual directory's physical path.

NOTE: w3svc/1/ means “Default Web Site”.
Q). How to Delete Virtual Directory Using VBScript with Command line?
A). You can use adsutil.vbs at Inetpub\AdminScripts directory.
cscript adsutil.vbs DELETE W3SVC\1\ROOT\YourVDirName
Q). How to Change Access to Virtual Directory Using VBScript with Command line?
A). You can use chaccess.vbs at Inetpub\AdminScripts directory.
chaccess <--ADSPath|-a relative config store path>
                          [--computer|-c COMPUTER1[,COMPUTER2...]]
                          [+read|-read]
                          [+write|-write]
                          [+script|-script]
                          [+execute|-execute]
                          [+browse|-browse]
                        [--verbose|-v]
                           [--help|-?]
cscript chaccess.vbs -a w3svc/1/ROOT/<Name Of Virtual Directory> +script +execute +read
cscript chaccess.vbs -a w3svc/1/ROOT/<Name Of Virtual Directory> -script -execute -read
Q). How to Convert Virtual Directory To ASP.NET Application Using VBScript with Command line?
A). You can use adsutil.vbs at Inetpub\AdminScripts directory.
cscript adsutil.vbs APPCREATEPOOLPROC w3svc/1/root/VDirName.
Q). What is the difference between wscript and cscript?
A). wscript is used while executing vbscripts through command line get the result in window based.
Cscript is used while executing vbscripts through command line get the result in console.
NOTE: More details to see vbscripts at inetpub\adminscripts.
Q). Why below error came? And what should I do?
ERROR:
Server Error in '/Events' Application.
--------------------------------------------------------------------------------
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to
access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS
metabase (e.g. IIS://servername/W3SVC). For information on modifying
metabase permissions, please see http://support.microsoft.com/?kbid=267904.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[HostingEnvironmentException: Failed to access IIS metabase.]
System.Web.Configuration.MetabaseServerConfig.MapP athCaching(String
siteID, VirtualPath path) +3591442
System.Web.Configuration.MetabaseServerConfig.Syst em.Web.Configuration.IConfigMapPath2.MapPath(Strin g
siteID, VirtualPath vpath) +9
System.Web.Hosting.HostingEnvironment.MapPathActua l(VirtualPath
virtualPath, Boolean permitNull) +169
System.Web.CachedPathData.GetConfigPathData(String configPath) +389
System.Web.CachedPathData.GetConfigPathData(String configPath) +243
System.Web.CachedPathData.GetApplicationPathData() +68
System.Web.CachedPathData.GetVirtualPathData(Virtu alPath virtualPath,
Boolean permitPathsOutsideApp) +3536567
System.Web.Configuration.RuntimeConfig.GetLKGRunti meConfig(VirtualPath
path) +189
A).
  1. Go to start àRun àtype cmd press Enter
  2. Change the directory to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (Note: Your application web.config existing version folder i.e 1.0, 2.0, 3.0, 3.5, 4.0.)
  3. iisreset /stop
  4. aspnet_regiis –i
  5. aspnet_regiis –c
  6. aspnet_regiis -ga ASPNET (Note:If you're using XP, the account is "ASPNET".
If you're using Server 2003, the account is "Network Service".
If you're using Vista, the account is "Network Service".)

Donot forget to give your comments /suggestions and refer to your friends.

No comments:

Post a Comment