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