'Brciis (Backup, Restore, Change Site IP) v1.0' This code refers to the "ASP programming control IIS to establish a web site" and AdsuTil.vbs, "I want to thank Envymask and Luoluo, thank you 'Little students are not very familiar with Adsi, so what is wrong in the code, please ask everyone to criticize, thank you' Codz by Blackfox, my QQ: 6858849 E-mail: ym2236@163.com Website: fox.he100.com ' Base On Adsutil.vbs Option Explicit 'On Error Resume Next Dim objArg, objInStream, objOutStream, intSiteIndex, objW3svc, ObjChildObject, strChildObjectName Dim objIIs, objIIsWeb, objFso, objBackupFile, arrServerBindings, strServerComment, strMaxConnections Dim strPath, strBackupFile, strFileLine, arrSiteInfo, intCreateWebStatus , strOldIP, strNewIP, intSiteCount Dim intBindsIndex, intBindsArrID, intChoice, strSearchMode, strSearchedSite, strSaveToBackup, strResult Dim strSaveFileName, strOverWrite, objResultFile, strIpString, intSearched, strDomainString, strPathString Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Set objOutStream = Wscript .Stdout set objinstream = wscript.stdin set objarg = wscript.Arguments if objarg.count <= 0 THEN HELP () WScript.quit End If SELEC T Case Ucase (Objarg (0)) Case "Backup" Help () backupsite () Case "rest" help () RESTORESISTE () CASE "changeip" help () changesiteip () case "change_app" Help () change_appisolated () card () change_Appisolated () "Search" help () Search () end select function backupsite () 'Backup Site Module ObjoutStream.write "Please enter the file name of the backup site information:" strbackupfile = Objinstream.readline INTSITEX = 1' site ID index WScript. Echo VBCRLF & "Start Backup Site Information ..." & VBCRLF '************************************************ ********* SET OBJW3SVC = GetObject ("IIS: // localhost / w3svc") 'Established IIS object for Each ObjchildObject in objW3SVC if (Err.Number <>
0) Then Exit For If IsNumeric (objChildObject.Name) = True Then 'is not determined ObjChildObject.Name digital Set objIIs = objW3svc.GetObject ( "IIsWebServer", objChildObject.Name) If Err.Number <> 0 Then Exit For Wscript. Echo "Error #" & "&" & "& Err.description Err.clear () wscript.quit end if arrserverBindings = objiis.serverbindings' ip, port, domain names of IIS virtual sites are released the maximum number of connections into an array ServerBindings strServerComment = objIIs.ServerComment 'the name of the IIS virtual site is assigned to the variable ServerComment strMaxConnections = objIIs.MaxConnections' the IIS virtual site is assigned to the variable MaxConnections Set objIIsWeb = objIIs.GetObject ( "IIsWebVirtualDir", "Root ") strPath = objIIsWeb.Path Set objFso = CreateObject (" Scripting.FileSystemObject ") If (objFso.fileexists (strBackupFile)) Then Set objBackupFile = objFso.OpenTextFile (strBackupFile, ForAppending, True) objBackupFile.WriteLine (strServerComment & vbTab & Join ( ArrserBindings, ") & vbtab & strmaxconnections & vbtab & strmaxconnections & vbtab & strm o b" 站 站 站 "& strserverComment &" Else Set ObjBackupFile = OB jFso.CreateTextFile (strBackupFile, True) objBackupFile.WriteLine (strServerComment & vbTab & Join (arrServerBindings, ",") & vbTab & strMaxConnections & vbTab & strPath) objBackupFile.Close Wscript.Echo "is the backup site" & strServerComment & "!" End If intSiteIndex = intSiteIndex 1 End If Next Wscript.Echo vbCrLf & "total backup" & intSiteIndex - 1 & "sites information!" & vbCrLf Set objW3svc = Nothing Set objChildObject = Nothing Set objIIs = Nothing Set objIIsWeb =
Nothing Set objFso = Nothing Set objBackupFile = Nothing End Function Function RestoreSite () 'recovery site module objOutStream.Write "Please enter the site information to restore the file name:" strBackupFile = objInStream.ReadLine Wscript.Echo vbCrLf & "resumed Site Information ...... "& vbCrLf Set objFso = CreateObject (" Scripting.FileSystemObject ") If not (objFso.fileexists (strBackupFile)) Then Wscrip.Echo" file "& strBackupFile &" not found! "& vbCrLf &" Make sure the location of the file! "Wscript. Quit End If Set objBackupFile = objFso.OpenTextFile (strBackupFile, 1) intSiteCount = 1 Do While objBackupFile.AtEndOfStream <> True strFileLine = objBackupFile.ReadLine arrSiteInfo = split (strFileLine, vbTab) intCreateWebStatus = CreateWebServer (arrSiteInfo (0), split (arrSiteInfo (1), ","), ArrsiteInfo (2), arrsiteinfo (3)) f = wscript.echo "Create Site" & ArrsiteInfo (0) & "Success" INTSITECOUNT = INTSITECUNT 1 else wscript.echo " Establishing Site "& ArrsiteInfo (0) &" Failed "End if loop objBackupfile.close WScript.echo VBCRLF &" A total of "& INTSITECUNT - 1 &" Site Information! "& Vbcrlf set objBackupFile = Nothing SET Objfso = Nothing end function function change ")" Modify Site IP Module '******************************************************* ********** 'Get two IPs, one is original, is a new' ********************** ********************* ObjoutStream.write "Please enter the site original IP:" strold = objinstream.readline objoutstream.write "Please enter the site new IP:" Strnewip = Objinstream.readline '**************************************************** WSCRIPT . Echo vbcrlf & "Start modification ..." & vbcrlf set objW3SVC = getObject ("
IIS: // localhost / w3svc ") 'establishment IIS Object For Each objChildObject In objW3svc If (Err.Number <> 0) Then Exit For If IsNumeric (objChildObject.Name) = True Then' is not determined objChildObject.Name digital Set objIIs = Objw3Svc.getObject ("IisWebserver", ObjchildObject.name) 'Establishing IIS virtual site logs if err.number <> 0 Then EXIT for WScript.echo "Error #" & cstr (Err.Number) & "& Err. Description Err.cler () wscript.quit end if arrserverBindings = objiis.serverbindings 'The value of IIS virtual site binds the value of the IIS virtual site into the array serverbindings strservercomment = objiis.servercomment' assigns the name of the IIS virtual site to the variable Servercomment wscript.echo "IP" & StrServerComment & "IP" "Prints in the command line" INTBINDSINDEX = Ubound (arrserverbindings) 1 'Since the site can bind multiple domain names, port and IP, so need to determine how much total bound IP For intBindsArrID = 1 to intBindsIndex If instr (arrServerBindings (intBindsArrID - 1), strOldIP) Then arrServerBindings (intBindsArrID - 1) = Replace (arrServerBindings (intBindsArrID - 1), strOldIP, strNewIP) 'the array Contains a string of Oldip replaces the string end if next objiis.serverbindings = arrserverbindings' for the IIS object SE RVERBINDINGS attributes modified to replace IP array objiis.setinfo 'makes the settings replace the settings END IF next' *********************************************************** ************************** SET OBJW3SVC = Nothing set objiis = Nothing set objiisweb = nothing wscript.echo vbcrlf & "modification complete!" End function function change_Appisolated () 'Modify Application Protection Module ObjoutStream.write "Select" 0, low _iis process 2, medium _ shared 3, high _ independent, default setting to 2): "intchoice = Objinstream.readline if not isnumeric (intchoice) THEN WScript.echo "Error, you are not entered!" wscript.quit end if tentEndex = 1 '
Site ID Index WScript.echo VBCRLF & "Starts to modify ..." & vbcrlf "**************************************** ************* SET OBJW3SVC = GetObject ("IIS: // LocalHost / W3SVC") 'Established IIS Object for Each ObjchildObject in ObjW3SVC IF (Err.Number <> 0) THEN EXIT for IF IsNumeric (objChildObject.Name) = True Then 'is not judged removed objChildObject.Name digital Set objIIs = objW3svc.GetObject ( "IIsWebServer", objChildObject.Name) If Err.Number <> 0 Then Exit For Wscript.Echo "Error # "& CStr (Err.Number) &" "& Err.Description Err.Clear () Wscript.Quit End If strServerComment = objIIs.ServerComment set objIIsWeb = objIIs.GetObject (" IIsWebVirtualDir "," Root ") objIIsWeb.AppIsolated = int (intChoice) objIIsWeb.SetInfo Wscript.Echo "setting Up Your site" & strServerComment & "complete!" End If Next set objW3svc = Nothing set objChildObject = Nothing set objIIs = Nothing set objIIsWeb = Nothing Wscript.Echo vbCrLf & "setup is complete!" End Function Function Search () 'Search Module WScript.echo "Please select Search Method:" & VBCRLF WScript.echo "1." WScript.echo "in accordance with the IP query site information" WScript.echo "3 according to the domain name query site information" WScript.echo "3. According to the site absolute path Inquiry site information "& vbrlf objoutstream.write" Please select the query method you need (1 2 3): "STRSEARCHMODE = Objinstream.readline Select Case StrsearchMode Case" 1 "USE_IP_SEARCH () Case" 2 "USE_DOMAIN_SEARCH () Case" 3 " Use_Path_Search () End Select End Function Function Use_IP_Search () 'information search site based on IP objOutStream.Write "Please enter the IP you want to search:" strIpString = objInStream.ReadLine Wscript.Echo "start Search ......" & vbCrLf intSiteIndex = 1'
*************************************************************** SET OBJW3SVC = GetObject "IIS: // localhost / w3svc") 'establishment IIS Object For Each objChildObject In objW3svc If (Err.Number <> 0) Then Exit For If IsNumeric (objChildObject.Name) = True Then' Set number is not determined objChildObject.Name Objiis = objw3svc.getObject ("IisWeb Server", ObjchildObject.name) 'Establishing IIS virtual site logs if err.Number <> 0 Then EXIT for WScript.echo "Error #" & CSTR (Err.Number) & "& Err .Description err.cle arrserBindings = objiis.serverbindings 'The value of IIS virtual site binds the value of the IIS virtual site, and the value of the value of the value of the domain serverbindings intbindsindex = ubound (arrserverbindings) 1' Due to the site can be bound multiple domains, ports, and IP, it is necessary to determine the total number of bundled IP intSearched = 0 For intBindsArrID = 1 To intBindsIndex If InStr (arrServerBindings (intBindsArrID - 1), strIpString) Then intSearched = 1 Exit For End If Next If intSearched = 1 Then strServerComment = objIIs.ServerComment 'the name of the IIS virtual site is assigned to the variable ServerComment strMaxConnections = objIIs.MaxConnections Wscript.Echo "site description:" & strServerComment Set objIIsWeb = objIIs.GetObject ( "IIsWebVirt ualDir "," Root ") strPath = objIIsWeb.Path strSearchedSite = strSearchedSite & strServerComment & vbTab & Join (arrServerBindings,", ") & vbTab & strMaxConnections & vbTab & strPath & vbCrLf intSiteIndex = intSiteIndex 1 End If End If Next 'Wscript . Echo strsearchedsite 'print out search Site Information if IntSiteIndex = 1 THEN WScript.echo VBCRLF & "Find Site Information!" Else Wscript.echo VBCRLF & "found" & INTSITEINDEX - 1 & "site!" WScript.echo "Default Shows only outline description, if you need more information, please save the search results as a file!"
ObjoutStream.write "Does Site information as backup files? (Yes, NO):" strsavetobackup = objinstream.readline if ucase (strsavetobackup) = "YES" Then Savetofile (strSearchedSite) end if end if '****** ******************************************************************************* SET OBJW3SVC = Nothing set objchildObject = Nothing set objiis = Nothing Set objIIsWeb = Nothing End Function Function Use_Domain_Search () 'domain name search module objOutStream.Write "Please enter the domain name you want to search:" strDomainString = objInStream.ReadLine Set objW3svc = GetObject ( "IIS: // LocalHost / W3svc") Wscript. echo "start Search ......" & vbCrLf intSiteIndex = 1 For Each objChildObject In objW3svc If (Err.Number <> 0) Then Exit For If IsNumeric (objChildObject.Name) = True Then 'is not determined objChildObject.Name digital Set objIIs = Objw3Svc.getObject ("IisWebserver", ObjchildObject.name) 'Establishing IIS virtual site logs if err.Number <> 0 Then EXIT for WScript.echo "Error #" & CSTR (Err.Number) & "& Err.Description Err.clear () wscript.quit end if arrserBindings = objiis.serverbindings' puts the value of IIS virtual sites to the value of the IIS virtual site, place the value of the array serverbindings intbindsindex = Ubound (Arrserverb) indings) 1 'because the domain can bind a plurality of domain names, and the IP ports, it is necessary to determine how much total bound IP intSearched = 0 For intBindsArrID = 1 To intBindsIndex If InStr (arrServerBindings (intBindsArrID - 1), strDomainString) Then intSearched = 1 Exit for End If Next If intSearched = 1 Then strServerComment = objIIs.ServerComment 'the name of the IIS virtual site is assigned to the variable ServerComment strMaxConnections = objIIs.MaxConnections Wscript.Echo "site description:" & strServerComment Set objIIsWeb = objIIs.GetObject ( "Iiswebvirtualdir", "root" StrPath =
objIIsWeb.Path strSearchedSite = strSearchedSite & strServerComment & vbTab & Join (arrServerBindings, ",") & vbTab & strMaxConnections & vbTab & strPath & vbCrLf intSiteIndex = intSiteIndex 1 End If End If Next 'Wscript.Echo strSearchedSite' to print out the search Site Information If INTSIDEX = 1 THEN WScript.echo VBCRLF & "Find Site Information!" Else Wscript.ech.echo Vbcrf & "found" & INTSITEINDEX - 1 & "site!" Wscript.echo "default only shows out site Description, if you need more information, please save the search results as files! "ObjoutStream.write" exists for the site information as a backup file? (YES, NO): "strsavetobackup = objinstream.readline if ucase (strsavetobackup) =" YES "THEN Savetofile (strSearchedSite) end if end if '*********************************************** ****** Set objW3svc = Nothing Set objChildObject = Nothing Set objIIs = Nothing Set objIIsWeb = Nothing End Function Function Use_Path_Search () 'domain name search module objOutStream.Write "Please enter the absolute path you want to search:" strPathString = objInStream. Readline set objW3SVC = getObject ("IIS: // localhost / w3svc") wscript.echo "Start Search ..." & vbcrlf IntSiteIndex = 1 for Each ObjchildObject in ObjW3SVC IF (Err.Number <> 0) Then Exit For If IsNumeric (objChildObject.Name) = True Then 'judgment is not objChildObject.Name digital Set objIIs = objW3svc.GetObject ( "IIsWebServer", objChildObject.Name)' establishment IIS virtual site on the image If Err.Number < > 0 THEN EXIT for WScript.echo "Error #" & "&" & Err.Description Err.clear () wscript.quit end if set objiisweb = objiis.getObject ("IisWebVirtualdir", "root"
) If instr (objIIsWeb.Path, strPathString) Then strServerComment = objIIs.ServerComment 'the name of the IIS virtual site is assigned to the variable ServerComment arrServerBindings = objIIs.ServerBindings' the value of the IIS virtual site bound IP, port, domain name into an array ServerBindings strMaxConnections = objIIs.MaxConnections strPath = objIIsWeb.Path Wscript.Echo "site description:" & strServerComment strSearchedSite = strSearchedSite & strServerComment & vbTab & Join (arrServerBindings, ",") & vbTab & strMaxConnections & vbTab & strPath & vbCrLf intSiteIndex = intSiteIndex 1 end if end if next 'wscript.echo strsearchedsite' print out search Site information if ing INTSITEINDEX = 1 THEN WScript.echo vbcrlf & "Find site information!" Else wscript.echo vbcrlf & "found" & " INTSITEINDEX - 1 & "Site!" wscript.echo "Default Displays only outline description, if you need more information, please save the search results as file!" ObjoutStream.write "Do you save the site information as a backup file? (Yes , NO): "strsavetobackup = objinstream.readline if ucase (strsavetobackup) =" yes "Then Savetofile (strSearchedSite) end if end if '********************* ******************************** SET OBJW3SVC = Nothing set objChildObject = Nothing set objiis = nothing set objIIsWeb = Nothing End Function Function SaveToFile (strResult) 'to save the file objOutStream.Write "Please enter save file name:" strSaveFileName = objInStream.ReadLine Set objFso = CreateObject ( "Scripting.FileSystemObject") If objFso.FileExists (strSaveFileName) Then Wscript "" & Strsavefilename & "already exists!" ObjoutStream.write "Is it appended to the file? (YES, NO) "stroverwrite = objinstream.readline if ucase (stroverwrite) =" yes "
Then Set objResultFile = objFso.OpenTextFile (strSaveFileName, ForAppending, True) objResultFile.Write strResult objResultFile.Close Wscript.Echo "write to file" & strSaveFileName & "complete!" End If If UCase (strOverWrite) = "NO" Then objOutStream. Write "Please rename the file:" strSaveFileName = objInStream.ReadLine Set objResultFile = objFso.CreateTextFile (strSaveFileName, True) objResultFile.Write strResult objResultFile.Close Wscript.Echo "save file" & strSaveFileNmae & End If Else Set objResultFile "complete!" = objFso.CreateTextFile (strSaveFileName, True) objResultFile.Write strResult objResultFile.Close Wscript.Echo "save file" & strSaveFileName & "complete!" End If Set objFso = Nothing End Function Function CreateWebServer (strServerComment, arrServerBindings, strMaxConnections, strPath) ' set up a site On Error Resume Next Set objW3svc = GetObject ( "IIS: // LocalHost / W3svc") intSiteIndex = 999 Do While IsObject (objW3svc.GetObject ( "IIsWebServer", intSiteIndex)) If Err.Number <> 0 Then 'Wscript. Echo err.description err.clear () EXIT DO END IF INT SiteIndex = IntSiteIndex - 1 loop set objiis = objw3svc.create ("IisWebserver", INTSITEINDEX) IF Err.Number <> 0 THEN WScript.echo "Error #" & CSTR (Err.Number) & "& Err.Description Err. Clear () CreateWebServer = 0 Exit Function End If objIIs.ServerSize = 1 objIIs.ServerComment = strServerComment objIIs.ServerBindings = arrServerBindings objIIs.MaxConnections = strMaxConnections objIIs.EnableDefaultDoc = True objIIs.SetInfo Set objIIsWeb = objIIs.Create ( "IIsWebVirtualDir", " Root
) If err.Number <> 0 THEN WScript.echo "Error #" & CSTR (Err.Number) & "&" & err.description Err.Clear () createwebserver = 0 exit function end if objiisweb.path = strpath objiisweb.accessreadRead = True objIIsWeb.AccessWrite = False objIIsWeb.EnableDirBrowsing = False objIIsWeb.EnableDefaultDoc = True objIIsWeb.AccessScript = True objIIsWeb.AppIsolated = 2 objIIsWeb.AppFriendlyName = "default application" objIIsWeb.SetInfo Set objW3svc = Nothing Set objIIs = Nothing Set objIIsWeb = Nothing createWebserver = 1 End function function help () wscript.echo "IIS total tube v1.5 by blackfox" wscript.echo "http://fox.he100.com" & vbcrlf
WScript.echo "CScript IIS_MANAGER-1.5.VBS Backup (Backup IIS Site Information to a Text File!)" WScript.echo "CScript Iis_Manager-1.5.vbs Restroe (Restore IIS Site Information from a text)!)" Wscript.echo " CScript IIS_MANAGER-1.5.VBS ChangeIP (Modify all IIS Site IP!) "WScript.echo" CScript IIS_MANAGER-1.5.VBS Change_App (Modify all IIS Site Applications Level!) "WScript.echo" CScript Iis_Manager-1.5.vbs Search Site information according to conditional search site!) "& Vbrlf end function 'Think of the new function' backup function adds a backup site data to the function, automatically packaged through the RAR, default package to the site's superior directory, you can choose the specified directory of the package 'to increase the establishment Hidden the function of the virtual directory 'Batch delete binding specified IIS runtime judgment if IIS is started pre>