VBScript基于WSH编程

  

大学时期也用过VBScript,不过都是基于ASP的,近期因工作需要,尝试在WSH (windows脚本主机)下编程,实现列示oracle客户端下以及。奥拉文件的主要信息(以及、主机SID),大体思路是:判断当前系统下甲骨文路径,从系统变量中读取具体路径,通过Wscript下的文件对象读取文件,分隔路,截取奥拉文件中的需要信息,下面是具体实现的脚本:

<人力资源/> option 明确   “提醒error  resume  next   call 主要   Sub 主要   dim 房屋=,homes  ReadOracleHome   ,call  ReadTNS(房屋)   最终获得子   日期:2014 - 10 - 15,   作者:艾伦   Function  ReadTNS(房屋)   ,dim  i, j, k, fs, ts, f, strAll, strTSNname (100), strHost (100), strServiceName(100),内容、内容(10),strTotal, txt   ,set  fs =WScript.CreateObject (“Scripting.FileSystemObject”)   ,For  i=0,用UBound(房屋)   If 才能;房屋(i), & lt;在“”,然后   ,,“判断tns文件是否存在   ,,If  fs.FileExists(中期(房屋(i), 1, Len(房屋(我)3),“网络\ admin \ tnsnames.ora”),=, true  Then ,,,   ,,,的读取tnsnames.ora文件   ,,,set  f=fs.getfile(中期(房屋(i), 1, Len(房屋(我)3),“网络\ admin \ tnsnames.ora”)   ,,,set  ts =, f.OpenAsTextStream (1,0)   ,,,do  while  ts.AtEndOfStream  & lt;祝辞,真的   ,,,,For  j=0,用100   ,,,,,if  ts.AtEndOfStream =true 然后   ,,,,,exit    ,,,,最终获得;如果   ,,,,,txt=ts.ReadLine   ,,,,,If  InStr (StrReverse(修剪(txt)),“=?=1,以及InStr(修剪(txt),“(”)=0,   ,,,,,,strTSNname (j)=StrReverse(中期(修剪(StrReverse (txt)), InStr(修剪(StrReverse (txt)),“=? + 1))   ,,,,,,”msgbox  strTSNname (j)   ,,,,,ElseIf  InStr (txt”(HOST =")在0,   ,,,,,,If  InStr (txt”) (PORT =")在0,   ,,,,,,,strHost (j)=修剪(SplitStr (txt”(HOST =薄ⅰ? (PORT ="))   ,,,,,,   ,,,,,,,strHost (j)=修剪(SplitStr (txt,”(HOST =", ")))   ,,,,,最终获得;如果   ,,,,,,”msgbox  strHost (j)   ,,,,,ElseIf  InStr (txt”(SERVICE_NAME=")在0,趁机InStr (txt”(SID =")在0,   ,,,,,,IF  InStr (txt”(SERVICE_NAME=")在0,   ,,,,,,,strServiceName (j)=修剪(SplitStr (txt, (SERVICE_NAME=", ")))   ,,,,,,ElseIf  InStr (txt”(SID =")在0,   ,,,,,,,strServiceName (j)=修剪(SplitStr (txt,”(SID =", ")))   ,,,,,最终获得;如果   ,,,,,,”msgbox  strServiceName (j)   ,,,,最终获得;如果   ,,,,,”msgbox  "以及=" + strTSNname (j) +“,,,主机=" + strHost (j) +“,,,,, SERVUCE_NAME/SID=" + strServiceName (j) + vbNewLine   ,,,下一个   ,,,循环   ,,,的去除数组中的空值   ,,,dim  a, b, c, nstrTSNname, nstrHost nstrServiceName   ,,,a=sumArrayNotNullValue (strTSNname)   ,,,b=sumArrayNotNullValue (strHost)   ,,,c=sumArrayNotNullValue (strServiceName),,,   ,,,nstrTSNname=, dropArrayNullValue (strTSNname, maxThree (a, b, c))   ,,,nstrHost=, dropArrayNullValue (strHost, maxThree (a, b, c))   ,,,nstrServiceName=, dropArrayNullValue (strServiceName, maxThree (a, b, c))   ,,,的组织文本显示效果   ,,,For  k=0,用maxThree (a, b, c)   ,,,,IF  nstrTSNname (k), & lt;在",以及nstrHost (k) & lt;在",以及nstrServiceName (k) & lt;在“,   ,,,,,If 内容=" ",然后   ,,,,,,内容="以及=" + addSpaceToString (getMaxLength (nstrTSNname) nstrTSNname (k)) + "主机=" + addSpaceToString (getMaxLength (nstrHost) nstrHost (k)) +”,才能SERVUCE_NAME/SID=" + nstrServiceName (k) + vbNewLine   ,,,,,,的内容="以及=" + nstrTSNname (k) +“,”+“主机=" + nstrHost (k) +“,”+“SERVUCE_NAME/SID=" + nstrServiceName (k) + + vbNewLine“,”   ,,,,,   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

VBScript基于WSH编程