waterye

          收集的Windows Script

          1' open ie
          2set ie=wscript.createobject("internetexplorer.application")
          3ie.width=800
          4ie.height=336
          5ie.resizable=0 
          6ie.navigate "http://www.aygfsteel.com/waterye/archive/2005/09/03/11886.aspx"
          7ie.visible=1
          8wscript.sleep 10000
          9ie.quit

           1' 顯示ip地址
           2strComputer = "."
           3Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
           4Set IPConfigSet = objWMIService.ExecQuery _
           5    ("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
           6For Each IPConfig in IPConfigSet
           7    If Not IsNull(IPConfig.IPAddress) Then 
           8        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
           9            WScript.Echo IPConfig.IPAddress(i)
          10    Next
          11    End If
          12Next

           1' 配置ip, subnetmask, gateway, dns servers
           2Set colNetAdapters = objWMIService.ExecQuery _
           3    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
           4strIPAddress = Array("192.168.0.6")
           5strSubnetMask = Array("255.255.255.0")
           6strGateway = Array("192.168.0.1")
           7strGatewayMetric = Array(1)
           8arrDNSServers = Array("202.96.128.166""202.96.128.86")    
           9For Each objNetAdapter in colNetAdapters
          10    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
          11    errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
          12    objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
          13    If errEnable = 0 Then
          14        WScript.Echo "The IP address has been changed."
          15    Else
          16        WScript.Echo "The IP address could not be changed."
          17    End If
          18Next

          1' 調用shell
          2Set WshShell = Wscript.CreateObject("Wscript.Shell"
          3WshShell.Run ("notepad " & Wscript.ScriptFullName)

          1' 調用COM對象
          2Set fs = Wscript.CreateObject("Scripting.FileSystemObject"
          3Set a = fs.CreateTextFile("file.txt"True
          4a.WriteLine("foo bar"
          5a.Close

           1' 刪除服務(小心操作)
           2strComputer = "."
           3Set objWMIService = GetObject("winmgmts:" _
           4& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
           5serviceName = "MySql"
           6Set colListOfServices = objWMIService.ExecQuery _
           7("Select * from Win32_Service Where Name = '" & serviceName & "'")
           8For Each objService in colListOfServices
           9    WScript.Echo objService.DisplayName
          10    objService.StopService()
          11    objService.Delete()
          12Next

           1' 顯示系統的最后啟動時間
           2strComputer = "."
           3Set objWMIService = GetObject _
           4    ("winmgmts:\\" & strComputer & "\root\cimv2")
           5Set colOperatingSystems = objWMIService.ExecQuery _
           6    ("Select * from Win32_OperatingSystem")
           7For Each objOS in colOperatingSystems
           8    dtmBootup = objOS.LastBootUpTime
           9    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
          10    Wscript.Echo "LastBootupTime: " & dtmLastBootupTime
          11Next
          12Function WMIDateStringToDate(dtmBootup)
          13    WMIDateStringToDate = CDate(Mid(dtmBootup, 52& "/" & _
          14         Mid(dtmBootup, 72& "/" & Left(dtmBootup, 4) _
          15         & " " & Mid (dtmBootup, 92& ":" & _
          16         Mid(dtmBootup, 112& ":" & Mid(dtmBootup, _
          17         132))
          18End Function

           1' 拔掉網線時都能收到通知
           2strComputer = "."
           3
           4Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
           5Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
           6    ("Select * from MSNdis_StatusMediaDisconnect"
           7
           8Do While True 
           9    Set strLatestEvent = colMonitoredEvents.NextEvent 
          10    Wscript.Echo "A network connection has been lost:"
          11    WScript.Echo strLatestEvent.InstanceName, Now
          12    Wscript.Echo 
          13Loop


          BTW: 使用"Windows Script Host"在emule上可找到不少ebook, 個人覺得Apress.-.Managing.Enterprise.Systems.with.the.Windows.Script.Host.2002.chm較好

          posted on 2005-11-28 22:37 waterye 閱讀(681) 評論(0)  編輯  收藏 所屬分類: windows


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 云安县| 涞源县| 苍山县| 永靖县| 古丈县| 巴林右旗| 浦北县| 永和县| 延寿县| 梁河县| 岐山县| 平阴县| 文山县| 江津市| 襄樊市| 滁州市| 宿迁市| 珲春市| 三门县| 海伦市| 安西县| 宜宾市| 桐庐县| 宜川县| 昌邑市| 美姑县| 安远县| 塔城市| 永兴县| 苗栗市| 宜都市| 麻栗坡县| 景德镇市| 宝兴县| 宽城| 西青区| 当阳市| 眉山市| 南郑县| 泸水县| 库车县|