使用JS创建虚拟目录,并引导进入浏览
使用JS,可以替代Windows安装方式:
代码也比较简单:)
创建一个setup.js文件,内容为:
会创建虚拟目录DotNetDemo虚拟目录,并且打开一个浏览器,浏览DotNetDemo虚拟目录中的default.aspx文件.
很简单,不罗嗦.
: 使用JS创建虚拟目录,并引导进入浏览 稍微改写了下,这样新建asp.net工程时只需要建立目录,复制过去,运行它就好了
var fso = new ActiveXObject("Scripting.FileSystemObject");
var svcPath = "IIS://localhost/W3SVC/1";
var svcRoot = GetObject(svcPath);
var webRoot = svcRoot.GetObject("IIsWebVirtualDir", "Root");
var scPath = fso.GetAbsolutePathName(".");
var sName = scPath.substr(scPath.lastIndexOf("\\")+1);
if(sName.length>0)
{
try
{
var objVDir1 = webRoot.Create("IIsWebVirtualDir", sName);
objVDir1.Path = scPath;
objVDir1.AppCreate(2);
objVDir1.AppFriendlyName = sName;
objVDir1.SetInfo();
}
catch(ex)
{
WScript.Echo(ex.description + "(" + ex.number + ")" )
}
var o = new ActiveXObject("WScript.NetWork");
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run("iexplore.exe http://" + o.ComputerName + "/" + sName +"/index.aspx");
}
else
{
WScript.Echo("不要把虚拟目录建立在根目录");
}
代码也比较简单:)
创建一个setup.js文件,内容为:
var fso = new ActiveXObject("Scripting.FileSystemObject")
var svcPath = "IIS://localhost/W3SVC/1"
var svcRoot = GetObject(svcPath)
var webRoot = svcRoot.GetObject("IIsWebVirtualDir", "Root")
try
{
var objVDir1 = webRoot.Create("IIsWebVirtualDir", "dbnetoffice")
objVDir1.Path = fso.GetAbsolutePathName(".")
objVDir1.AppCreate(2)
objVDir1.AppFriendlyName = "DotNetDemo"
objVDir1.SetInfo()
}
catch(ex)
{
// WScript.Echo(ex.description + "(" + ex.number + ")" )
}
var o = new ActiveXObject("WScript.NetWork")
var wshShell = new ActiveXObject("WScript.Shell")
wshShell.Run("iexplore.exe http://" + o.ComputerName + "/DotNetDemo/default.aspx")
var svcPath = "IIS://localhost/W3SVC/1"
var svcRoot = GetObject(svcPath)
var webRoot = svcRoot.GetObject("IIsWebVirtualDir", "Root")
try
{
var objVDir1 = webRoot.Create("IIsWebVirtualDir", "dbnetoffice")
objVDir1.Path = fso.GetAbsolutePathName(".")
objVDir1.AppCreate(2)
objVDir1.AppFriendlyName = "DotNetDemo"
objVDir1.SetInfo()
}
catch(ex)
{
// WScript.Echo(ex.description + "(" + ex.number + ")" )
}
var o = new ActiveXObject("WScript.NetWork")
var wshShell = new ActiveXObject("WScript.Shell")
wshShell.Run("iexplore.exe http://" + o.ComputerName + "/DotNetDemo/default.aspx")
会创建虚拟目录DotNetDemo虚拟目录,并且打开一个浏览器,浏览DotNetDemo虚拟目录中的default.aspx文件.
很简单,不罗嗦.
: 使用JS创建虚拟目录,并引导进入浏览 稍微改写了下,这样新建asp.net工程时只需要建立目录,复制过去,运行它就好了
var fso = new ActiveXObject("Scripting.FileSystemObject");
var svcPath = "IIS://localhost/W3SVC/1";
var svcRoot = GetObject(svcPath);
var webRoot = svcRoot.GetObject("IIsWebVirtualDir", "Root");
var scPath = fso.GetAbsolutePathName(".");
var sName = scPath.substr(scPath.lastIndexOf("\\")+1);
if(sName.length>0)
{
try
{
var objVDir1 = webRoot.Create("IIsWebVirtualDir", sName);
objVDir1.Path = scPath;
objVDir1.AppCreate(2);
objVDir1.AppFriendlyName = sName;
objVDir1.SetInfo();
}
catch(ex)
{
WScript.Echo(ex.description + "(" + ex.number + ")" )
}
var o = new ActiveXObject("WScript.NetWork");
var wshShell = new ActiveXObject("WScript.Shell");
wshShell.Run("iexplore.exe http://" + o.ComputerName + "/" + sName +"/index.aspx");
}
else
{
WScript.Echo("不要把虚拟目录建立在根目录");
}