百度空间 | 百度首页 
 
查看文章
 
断开并重连iSCSI虚拟盘的脚本
2007-09-01 16:39

本脚本用在服务器ccdisk1.3 客户端微软1.06和2.0都行,如果服务端用的是别的,请自行修改“iqn.2005-02.com.ricecake.iscsi:00”  

Dim fso,oShell   
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "SID.bat",0,true
If fso.DriveExists("G") Then       '这个G改为你的虚拟盘的盘符号
     oShell.run ("iscsicli logouttarget "&ReadSID),0,true:
     WScript.Sleep 1000
end if
If fso.DriveExists("G") Then       '这个G改为你的虚拟盘的盘符号
     oShell.run ("iscsicli logouttarget "&ReadSID),0,true:
     WScript.Sleep 1000
end if
If fso.DriveExists("G") Then       '这个G改为你的虚拟盘的盘符号
     Msgbox "虚拟盘正使用中,请检查是否某些程序正在使用虚拟盘,"& vbCrLf &"包括虚拟光驱里的镜像文件是不是虚拟盘的,如果有,"& vbCrLf &"请先关闭这些程序和窗口然后再执行本操作。",64,"虚拟盘断开失败":
     Wscript.quit
end if
If (fso.FileExists(oShell.ExpandEnvironmentStrings("%WinDir%")&"\system32\iscsicpl.cpl")) Then
     oShell.run "iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0",0,true
End If
Function ReadSID
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Dim f
    Set f = fso.OpenTextFile("C:\sid.txt", ForReading)
    f.skip(25)
    ReadSID = f.Read(33)
End Function

============================================================

SID.bat如下

iscsicli sessionlist|find "Session Id">C:\SID.txt


类别:技术日志 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu