wgboy 发表于 2010-11-23 13:43:35

向局域网电脑启动文件夹写入文件

此程序主要是为了实现向局域网内的电脑启动文件夹,复制一个程序。不知道有没有类似多线程去映射然后复制。。这样就可以节约很多时间。高手们,有玩过类似经历告诉一声。$sUserName = "fa1"
$sPassword = "Coe123"

$file = FileOpen("C:\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("Z:", "\\" & $ipadd & "\c$\Documents and Settings\All Users\Start Menu\Programs\Startup", 0, $sUserName, $sPassword)
        If $mapadd = 1 Then
                $path = "\\" & $ipadd & "\c$"
                fcp()
        Else
                $mapadd = DriveMapAdd("Z:", "\\" & $ipadd & "\d$\Documents and Settings\All Users\Start Menu\Programs\Startup", 0, $sUserName, $sPassword)
                If $mapadd = 1 Then
                        $path = "\\" & $ipadd & "\d$"
                        fcp()
                Else
                        $path = "无法映射"
                        fcp()
                EndIf
        EndIf

WEnd

FileClose($file)


Func fcp()

        If FileCopy("\\server\data$\softlist.exe", "Z:\", 1) Then
                $cpcheck = "成功"
        Else
                $cpcheck = "失败"
        EndIf

        $file2 = FileOpen("\\server\data$\test.txt", 1)

        If $file2 = -1 Then
                MsgBox(0, "错误", "不能打开LOG文件.")
                Exit
        EndIf
        If $ipadd <> "" Then
                FileWriteLine($file2, $ipadd & " | " & $path & " | " & $cpcheck)
        EndIf
        FileClose($file2)
        DriveMapDel("Z:")
EndFunc   ;==>fcp

nxbigdaddy 发表于 2010-11-23 14:19:56

不错啊,为什么要复制呢?
为什么不考虑让每个机器都来下载程序到本机呢?

wgboy 发表于 2010-11-23 16:23:16

回复 2# nxbigdaddy
那样的话,那还是要每台机器装有下载功能的客户端啊。
页: [1]
查看完整版本: 向局域网电脑启动文件夹写入文件