获取ip
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration ")DIP = ""dim xdim IPAddr(255)x = 0For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) If Not (IPConfig.IPAddress(i)="0.0.0.0") Then IPAddr(x) = IPConfig.IPAddress(i) x = x + 1 End if Nextend ifnext' msgbox "First IP is: " & IPAddr(0)' if more IP's exist, they will be in IPAddr(1), IPAddr(2) and so on'Session.Property("EDIT_WCFIP")=IPAddr(0)Session.Property("ODBC_RES_PROP")=IPAddr(0)验证连接:
Session.Property("validate_sqlconn") = "1" '先让验证通过
Session.Property("TXT_SQL_ERR") = "" '清空验证信息Dim objConnection
Set objConnection = CreateObject("ADODB.CONNECTION")dim connStrParam
connStrParam = Session.Property("EDIT_CONNSTR")Dim connStr
connStr = "provider=sqloledb;Initial Catalog=master;" & connStrParamon error resume next
objConnection.Open connStrIf Err.Number <> 0 Then Session.Property("validate_sqlconn") = "0" Session.Property("TXT_SQL_ERR") = "连接失败!"& Err.Description Err.ClearELSE If (objConnection.State <> 1) Then Session.Property("validate_sqlconn") = "0" Session.Property("TXT_SQL_ERR") = "连接失败!未知错误。" else dim overwrite if (Session.Property("CHK_DB_OVERWRITE") = "CheckBox") then Session.Property("CHK_Exist_Exam") = "100" Session.Property("CHK_Exist_Training") = "100" Session.Property("CHK_Exist_Structure") = "100" Session.Property("CHK_Exist_Resource") = "100" 'msgbox "123" else 'msgbox "1234" Dim objRecordSet Set objRecordSet = CreateObject("ADODB.RECORDSET")Dim objCommand
Set objCommand = CreateObject("ADODB.COMMAND") objCommand.ActiveConnection = objConnectionobjCommand.CommandText = "select * from sysdatabases where name='" & Session.Property("DB_Name_Exam") & "'"
objRecordSet.CursorLocation = 3 objRecordSet.Open objCommand dim count1 count1 = objRecordSet.RecordCount if (count1 > 0) then Session.Property("CHK_Exist_Exam") = "1" else Session.Property("CHK_Exist_Exam") = "100" END IF objRecordSet.closeSet objCommand = Nothing
Set objRecordSet = Nothing end if End Ifset objConnection = Nothingend if'msgbox Session.Property("EDIT_Server")检测端口:
Session.Property("validate_webport") = "1" '先让验证通过
Session.Property("TXT_WEBPORT_ERR") = "" '清空验证信息dim port
port = Session.Property("EDIT_WEBPORT")'msgbox portif(port = "") THEN Session.Property("validate_webport") = "0" Session.Property("TXT_WEBPORT_ERR") = "端口号不能为空!"elseif(port <= 0) THEN Session.Property("validate_webport") = "0" Session.Property("TXT_WEBPORT_ERR") = "无效的端口号!"else Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("netstat -an") Set oStdOut = oExec.StdOut Do Until oStdOut.AtEndOfStream strLine = oStdOut.ReadLine If InStr(strLine, ":" & port) > 0 And InStrRev(strLine, "ESTABLISHED") > 0 Then Session.Property("validate_webport") = "0" Session.Property("TXT_WEBPORT_ERR") = "端口已被占用!" Exit Do End If LoopEnd If删除目录:
set fso=createobject("scripting.filesystemobject")
on error resume nextdim tartar = Session.Property("APPDIR") msgbox tarset sfold = fso.getfolder(tar)sfold.attributes=0sfold.delete