'======================================================================= ' Microsoft provides programming examples for illustration only, ' without warranty either expressed or implied, including, but ' not limited to, the implied warranties of merchantability ' and/or fitness for a particular purpose. It is assumeed ' that you are familiar with the programming language being ' demonstrated and the tools used to create and debug procedures. ' Microsoft support professionals can help explain the functionality ' of a particular procedure, but they will not modify these examples ' to provide added functionality or construct procedures to meet your ' specific needs. If you have limited programming experience, you may ' want to contact a Microsoft Certified Partner or the Microsoft fee-based ' consulting line at (800) 936-5200. For more information about Microsoft ' Certified Partners, please visit the following Microsoft Web site: ' http://www.microsoft.com/partner/referral/ ' '========================Start of the script========================= Err.clear 'On Error Resume Next 'check the parameter here Set strArgus = Wscript.Arguments If strArgus.Count <> 1 Then Wscript.echo "please input the import source excel file as a paramter" Wscript.echo "For example: cscript DiskRaid.vbs 0" Wscript.quit End If subnumber = strArgus(0) Set objShell = CreateObject("WScript.Shell") 'Set objExecCmd = objShell.Exec("ipconfig") 'Set objStdOut = objExecCmd.StdOut Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set fileHandle1 = objFSO.CreateTextFile("s1.txt",ForWriting,false) fileHandle1.writeline "sel sub " & subnumber fileHandle1.writeline "list pools" fileHandle1.writeline "exit" strcmd1 = "diskraid /s s1.txt" Set objExecCmd = objShell.Exec(strcmd1) Set objStdOut = objExecCmd.StdOut 'Set objStdOut = objFSO.OpenTextFile("S1.log", ForReading) strList = "" strNameList = "" flag = false number = 0 totalnumber = 0 endflag = false While Not objStdOut.AtEndOfStream strLine = objStdOut.ReadLine If Instr(strline,"list pools") > 0 then flag = true ElseIf Instr(strline,"DISKRAID> exit") > 0 then endflag = true ElseIf (flag = true) AND (endflag = false) then If Trim(strline) <> "" then number = number + 1 End If totalnumber = totalnumber + 1 If strList = "" then strList = strLine Else strList = strList & ";" & strLine End If End If Wend objStdOut.close 'wscript.echo strList If number < 3 then wscript.quit End If Set fileHandle = objFSO.CreateTextFile("s2.txt",ForWriting,false) fileHandle.writeline "sel sub 0" 'number = number - 2 For i = 0 to (number - 3) fileHandle.writeline "sel pool " & i fileHandle.writeline "det pool" Next fileHandle.writeline "exit" 'Set objStdOut = objFSO.OpenTextFile("S2.log", ForReading) strcmd2 = "diskraid /s s2.txt" Set objExecCmd = objShell.Exec(strcmd2) Set objStdOut = objExecCmd.StdOut While Not objStdOut.AtEndOfStream strLine = objStdOut.ReadLine If Instr(strline,"det pool") > 0 then flag = true While flag strLine = objStdOut.ReadLine If Trim(strLine) <> "" then arrname = split(strLine,":") name = Trim(arrname(1)) If strNameList = "" then strNameList = name Else strNameList = strNameList & ";" & name End If flag = false End If Wend End If Wend arr = split(strList,";") 'for each item in arr ' wscript.echo item 'Next arr2 = split(strNameList,";") 'for each item in arr2 ' wscript.echo item 'Next for i = 0 to 1 wscript.echo arr(i) Next For i = 0 to (number - 3) 'wscript.echo arr(i + totalnumber - number + 1) 'wscript.echo i infor = arr(i + totalnumber - number) replaceitem = Left(arr2(i),20) wscript.echo Replace(infor,replaceitem,arr2(i)) Next