Jump to content
Sign in to follow this  
ruan

Copy file from server to multiple network pc's

Recommended Posts

ruan

Hi

I have searched the forums but cant find anything that will suit my needs! I am pretty new to autoit and would greatly appreciate some help.

I have a file on a server that i need to copy to about 130 computers into the all users startup folder. now, what would you say is the best way of doing this? i need it to read an excell file with the pc names and then copy it to that specific folder.

thanks for any help!

Share this post


Link to post
Share on other sites
PsaltyDS

With the Excel.au3 UDF, you could read the PC names out of an Excel file, but if you're really new to AutoIt it would probably be easier to export that list to a .CSV, .INI, or just .TXT file and read them from there.

Another possibility is if these machines are all in a domain you could have a login script or windows startup script policy that checks for the file and downloads it if required.

Either way you just test for the file with FileExists() and copy it with FileCopy(). Might be extra steps if you have to authentication to each machine.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Uten

Hello and welcome to the the forum.

Although it is nice to have someone do ones work from time to time I think this is a rather broad question from and "administrator". If your not the administrator of those computers then this is none of your business.

Take a look at the help file. There you will find a section called File, Directory and Disk management.

To figure out the excel part search with this term in the search box.

+excel +udf

If you provide more specific questions regarding code you have figured out, I will probably be able to give you a better answer.

Happy Scripting

Uten

Share this post


Link to post
Share on other sites
powaking

Hello and welcome to the the forum.

Although it is nice to have someone do ones work from time to time I think this is a rather broad question from and "administrator". If your not the administrator of those computers then this is none of your business.

Take a look at the help file. There you will find a section called File, Directory and Disk management.

To figure out the excel part search with this term in the search box.

+excel +udf

If you provide more specific questions regarding code you have figured out, I will probably be able to give you a better answer.

Happy Scripting

Uten

This is what I use:

#include <file.au3>
#include <array.au3>
#include <guiconstants.au3>
#include <Process.au3>

Dim $list, $machine
if fileexists("config.ini") Then
    $share = iniread("config.ini","Settings","share","")
    $name = iniread("config.ini","Settings","name","NAME")
    $file = iniread("config.ini","Settings","file","")
    $loc = iniread("config.ini","Settings","location","")
    $log = iniread("config.ini","Settings","log","LOG") & ".log"
Else
    fileinstall("config.ini","config.ini")
    sleep(500)
    _rundos("start notepad config.ini")
    Exit
EndIf

if $name = "" or $file = "" or $log = "" Then
    msgbox(48,"Incorrect Configuration","Please populate values in config.ini",15)
    _rundos("start notepad config.ini")
    Exit
EndIf

$count = _FileCountLines("machinelist.txt")
guicreate($name,250,100,-1,-1)
$machine = GUICtrlCreateLabel("",10,10,230,20)
$machine2 = GUICtrlCreateLabel("",10,30,230,20)
$progress = GUICtrlCreateProgress(10,60,230,20)

AutoItSetOption ( "RunErrorsFatal",0)

if not _FileReadToArray("machinelist.txt",$list) Then
    msgbox(48,"Error","Error reading machinelist.txt." & @CRLF & "Possibly missing machinelist.txt",15)
    Exit
EndIf

$start = 0
$number = 0
$percent = 100/$count
GUISetState()

For $x = 1 To $list[0]
    $number = $number + 1
    If $number = $count + 1 Then ExitLoop
    $start = $start + $percent
    GUICtrlSetData($machine2,"Machine " & $number & " of " & $count)
    GUICtrlSetData($machine,"Updating machine: " & $list[$x])
    GUICtrlSetData($progress,$start)
    ;If stringleft($list[$x],2)="LS" Then
    ;   $drive = Drivemapadd("*","\\" & $list[$x] & "\" & $loc,1,"pds","pdsugn")
    ;Else
    ;   $drive = Drivemapadd("*","\\" & $list[$x] & "\" & $loc)
    ;EndIf
    $drive = drivemapadd("*","\\" & $list[$x] & "\" & $share,8)
    
    If @error = 1 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Undefined / Other error: " & $list[$x])
    Elseif @error = 2 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Access to the remote share was denied: " & $list[$x])
    elseif @error = 3 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"The device is already assigned: " & $list[$x])
    elseif @error = 4 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Invalid device name: " & $list[$x])
    elseif @error = 5 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Invalid remote share: " & $list[$x])
    elseif @error = 6 Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Invalid password: " & $list[$x])
    Else
    ;$ver = filegetversion($drive & "\" & $file)
    ;_FileWriteLog(@ScriptDir & "\" & $log,$list[$x] & ": " & $ver)

    ;if filegetversion($drive & "\" & $file) < "6.8" Then
    
    ;filedelete($drive & "\" & $file)
    
    ;_filecopy(@scriptdir & "\" & $file,'"\\' & $list[$x] & "\" & $loc & '"')
    ;RunWait('cmd /c copy "' & $file & '" "\\' & $list[$x] & '\' & $loc & '" /Y',@SCRIPTDIR,@SW_HIDE)
    _filecopy(@scriptdir & "\" & $file,$drive & $loc)
    if fileexists($drive & $loc & "\" & $file) = "1" Then
        _FileWriteLog(@ScriptDir & "\" & $log,"Successful copying to: " & $list[$x])
    Else
        _FileWriteLog(@ScriptDir & "\" & $log,"NOT Successful copying to: " & $list[$x])
    EndIf
    
    Drivemapdel($drive) 
    EndIf

Next

config.ini

[Settings]
share=
name=
file=
location=
log=

[Example]
share=Share name
name=Input the name of the window
file=Name of the file you want to copy
location=Where you want to copy it to. Start with \ as the root folder of the share
log=Name of the log file to create. Will only report failures.

Populate machinelist.txt with names of machines. Edit code to your likings. I'm sure someone would make this prettier, please do and share.

Share this post


Link to post
Share on other sites
ruan

Hello and welcome to the the forum.

Although it is nice to have someone do ones work from time to time I think this is a rather broad question from and "administrator". If your not the administrator of those computers then this is none of your business.

Take a look at the help file. There you will find a section called File, Directory and Disk management.

To figure out the excel part search with this term in the search box.

+excel +udf

If you provide more specific questions regarding code you have figured out, I will probably be able to give you a better answer.

Happy Scripting

Uten

i do not understand the bit of hostility from you in this reply! and i am the administrator, i am the administrator of about 3500 pc's at my site. i thought i would expand my knowledge and try autoit, i guess if you are new to something you shouldnt ask you a question, i wonder who helped you when you first started. im not looking for someone to do my work for me, i was looking for some help in something completely new for me!

thanks for the "help"

and to the rest that replied, thanks!!

Share this post


Link to post
Share on other sites
Uten

i do not understand the bit of hostility from you in this reply!

...

thanks for the "help"

...

If you are, what you say you are, you should know better.

And yes, I as ask stupid questions to but I think they tend to be rather specific.

I also pointed you in the right direction in my "hostile" post.

But all in all, don't let this start hinder you from enjoying AutoIt. Any administrator should love the AutoIt set of tools...:)

Have fun scripting.

Regards

Uten

EDIT: Removed some of the quoted text.

Edited by Uten

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×