本脚本用在服务器ccdisk1.3 客户端微软1.06和2.0都行,如果服务端用的是别的,请自行修改“iqn.2005-02.com.ricecake.iscsi:00” [http://www.6iyn.com]
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 "
WScript.Sleep 1000
end if
If fso.DriveExists("G") Then '这个G改为你的虚拟盘的盘符号
oShell.run ("iscsicli logouttarget "
WScript.Sleep 1000
end if
If fso.DriveExists("G") Then '这个G改为你的虚拟盘的盘符号
Msgbox "虚拟盘正使用中,请检查是否某些程序正在使用虚拟盘," vbCrLf vbCrLf
Wscript.quit
end if
If (fso.FileExists(oShell.ExpandEnvironmentStrings("%WinDir%") Then
oShell.run "iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0",0,true [http://www.6iyn.com]
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