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 閱讀(682) 評論(0)  編輯  收藏 所屬分類: windows


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


          網站導航:
           
          主站蜘蛛池模板: 泸州市| 西林县| 天柱县| 海丰县| 突泉县| 二连浩特市| 高唐县| 湛江市| 怀柔区| 上高县| 遵义市| 苗栗市| 呼伦贝尔市| 张家界市| 滦南县| 康平县| 东阳市| 克东县| 阿拉善右旗| 阳新县| 磐安县| 沧源| 大同县| 印江| 剑阁县| 永丰县| 山阴县| 吐鲁番市| 盐亭县| 高雄县| 铜鼓县| 泾阳县| 阿拉善左旗| 澳门| 湖南省| 海宁市| 万源市| 昌平区| 正镶白旗| 竹溪县| 五莲县|