wgboy 发表于 2010-5-14 13:37:05

求读取局域网内机器的启动文件夹内容

求读取局域网内机器的启动文件夹内容,那位大哥能指出我的脚本错误,或者给个源码.#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
                $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

wgboy 发表于 2010-5-14 15:48:10

怎么就没人呢?高手们都看不见么?....自己先顶下

yuxw 发表于 2010-5-15 15:06:04

Documents and Settings\All Users\Start Menu\Programs\Startup
如果为中文系统请用中文:
「开始」菜单\程序\启动

wgboy 发表于 2010-5-17 10:11:19

那个路径是没错的,,我们用的是英文系统..关键是循环的问题
页: [1]
查看完整版本: 求读取局域网内机器的启动文件夹内容