求读取局域网内机器的启动文件夹内容,那位大哥能指出我的脚本错误,或者给个源码.#include <File.au3>
$sUserName="admin"
$sPassword="Pass123456"
$file = FileOpen("\\172.18.72.170\data$\ip.txt", 0)
If $file = -1 Then
MsgBox(0, "错误", "不能打开IP文件.")
Exit
EndIf
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
$ipadd = StringStripWS($line,8)
;MsgBox(0, "读取的行:", $ipadd)
$mapadd=DriveMapAdd("X:", "\"&$ipadd&"\c$\Documents and Settings\All Users\Start Menu\Programs\Startup", 0, $sUserName, $sPassword)
If $mapadd =1 Then
$path= "\"&$ipadd&"\c$"
_FileRecur("X:")
DriveMapDel("X:")
Else
$mapadd=DriveMapAdd("X:", "\"&$ipadd&"\d$\Documents and Settings\All Users\Start Menu\Programs\Startup", 0, $sUserName, $sPassword)
If $mapadd=1 Then
$path= "\"&$ipadd&"\d$"
_FileRecur("X:")
Else
$path= "无法映射"
$file2 = FileOpen("\\172.18.72.170\data$\search.txt", 1)
If $file2 = -1 Then
MsgBox(0, "错误", "不能打开LOG文件.")
Exit
EndIf
FileWriteLine($file2,$ipadd&Chr(32)&$path)
FileClose($file2)
EndIf
EndIf
Wend
FileClose($file)
Func _FileRecur($_Path)
$folder = _FileListToArray($_Path, "*", 1)
If Not IsArray($folder) Then Return 0
For $o = 1 To $folder[0]
$file2 = FileOpen("\\172.18.72.170\data$\search.txt", 1)
If $file2 = -1 Then
MsgBox(0, "错误", "不能打开LOG文件.")
Exit
EndIf
FileWriteLine($file2,$ipadd&Chr(32)&$path&Chr(32)&$folder[$o])
FileClose($file2)
_FileRecur($_Path & "" & $folder[$o])
Next
DriveMapDel("X:")
EndFunc
|