我正在使用VBScript,我的目标是能够将我选择的路径替换为驱动器字母。我需要D盘,如果不可用,我需要检查它是否已映射到正确的位置;然后通知用户。我找到了这个:http://technet.microsoft.com/en-us/library/ee156605.aspx,我正在尝试适应他们的第二个示例:
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("cmd /c ping -n 3 -w 1000 157.59.0.1")
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadLine()
If Instr(strText, "Reply") > 0 Then
Wscript.Echo "Reply received."
Exit Do
End If
Loop
(my adaptations):
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("cmd /c substr")
strText = ""
Do While Not objExecObject.StdOut.AtEndOfStream
strText = strText & objExecObject.StdOut.ReadLine()
Loop
Wscript.Echo strText
然后我可能会搜索指示D盘映射位置的字符串。 我还尝试了objShell.Exec("subst")
,但是我仍然没有得到任何输出。 有人对我做错了什么有想法吗?或者有更好的方法来查找驱动器映射吗?谢谢。
213897