VBScript config IIS

xiaoxiao2021-03-06  88

Weird, my IIS is installed, IIS manager cannot open, but IIS service can use it normally, and .NET established ASP project can run normally. Helpless, only by script config. My: set root = getObject ("IIS: / / localhost / w3svc / 1 / root") 'My documents コピ コピ set wshshell = wscript.createObject ("wscript.shell")' 仮 仮 ディレ ト ト リ 作 作 作 作 作 作 作 作 作 作"WshShell.Run" cmd.exe / c iisreset -start ", 0, True Set AppRoot = Root.Create (" IISWebVirtualDir "," TestScript ") AppRoot.AppCreate2 2AppRoot.AppFriendlyName =" TestScript "AppRoot.Path = Root.Path & "/TestScript "Approot.setinfo()Root.setInfo()// only knows to build, will not be deleted. Fortunately, there is a brother tip:

Referring to the Inetpub / AdminScripts / adsutil.vbs create a virtual directory to write the script: '// begin // On Error Resume NextstrVirtualDirectoryName = InputBox ( "Please enter the virtual directory name") If strVirtualDirectoryName = "" Then msgbox ( "input error, The program ends! ") WScript.quites IFSTRVIRTUALDIRIRECTORPATH = INPUTBOX (" Please enter the directory name where the website file is located (for example: E: / Web) ") if strvirtualdirectorypath =" "THEN MSGBOX (" Input error, program end! ") WScript. QuitEnd IfstrVirtualDirectoryPath = Replace (strVirtualDirectoryPath, "/", "/") Set MyFso = CreateObject ( "Scripting.FileSystemObject") If MyFso.FolderExists (strVirtualDirectoryPath) = 0 then msgbox ( "folder" & strVirtualDirectoryPath & "does not exist!") Else Set objiis = getObject ("IIS: / / root") set objvirtualdirectory = objiis.create ("IisWebVirtualDir", strvirtualdirectoryName) if (err.Number <> 0) Then 'If the virtual directory already exists or When other errors are true err.clear set mydir = objiis.getObject ("IisWebVirtualDir", create a virtual directory object if (err.Number <> 0) The 'virtual directory does not exist, explains others Unknown mistake, otherwise MsGBox already exists for the virtual directory ("Sorry, an unknown error, operation failure!") WScript.quit (Err.Number) end if m = msgbox ("virtual directory" & strvirtualdirectoryName & "Is there, is it deleted? ", 1 32," Delete Confirmation ") IF M <> 1 THEN WScript.quit End if Objiis.delete" IISObject ", StrvirtualDirectoryName if (Err.Number <> 0) THEN MSGBOX (" Delete Virtual Directory "& StrvirtualDirectoryName &" failed ") WScript.quit (Err.Number) end if set objvirtualdirectory = objiis.create (" IisWebVirtualdir "

, StrVirtualDirectoryName) objVirtualDirectory.AccessScript = true objVirtualDirectory.Path = strVirtualDirectoryPath objVirtualDirectory.EnableDefaultDoc = True objVirtualDirectory.DefaultDoc = "index.htm" objVirtualDirectory.AppFriendlyName = strVirtualDirectoryName objVirtualDirectory.SetInfo objVirtualDirectory.AppCreate true 'bolInProcessApplication msgbox ( "Successful operation! Virtual directory" & strVirtualDirectoryName & "successfully established," & vbCrLf & "Please enter in the browser address bar http: // localhost /" & strVirtualDirectoryName & "/ see the effect") else objVirtualDirectory.AccessScript = true objVirtualDirectory.Path = strVirtualDirectoryPath objVirtualDirectory.EnableDefaultDoc = True objVirtualDirectory.DefaultDoc = "successful operation of the virtual directory!" "index.htm" objVirtualDirectory.AppFriendlyName = strVirtualDirectoryName objVirtualDirectory.SetInfo objVirtualDirectory.AppCreate true 'bolInProcessApplication msgbox (& strVirtualDirectoryName & "successfully established," & vbCrLf & "Please enter in the browser address bar http: // localhost / "& strvirtualdirectoryName &" / View Effect ") end ifnd ifset myfso = Nothing '// end // Refer to the above script when making a installed ASP program. The above programs can also be rewritten as an ASP script, just pay attention when running the ASP page, the anonymous login user of the virtual directory in the ASP page must be an Administrator, otherwise the browser will prompt the permissions! The same manner can also be used to create a web site, which can be referred to INETPUB / Adminscripts / Adsutil.vbs. Author Blog:

http://blog.9cbs.net/possible_y/

转载请注明原文地址:https://www.9cbs.com/read-106871.html

New Post(0)