korsg Posted August 17, 2006 Share Posted August 17, 2006 Hello i am making a little backup script at my work that copies specific files from different network places. I made an GUI as an control panel that writes the IP adresses of locations to a INI file.. Heres a little view of the ini file: (backup.ini) ------------------------------ [1] IP=\\172.16.23.10\hc [2] IP=\\172.16.22.10\hc [3] IP=\\172.16.21.10\hc [4] IP=\\172.16.4.10\hc [5] IP=\\172.16.14.10\hc [6] IP=\\172.16.2.10\hc ------------------------------- And then one of my attempts look like this $source = IniRead("C:\Backup\backup.ini", "1", "IP","error") $dest = "C:\backup" $var = IniReadSectionNames("C:\Backup\backup.ini") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0] $var = RunWait(@ComSpec & ' /c xcopy "'& $source & '"\file.exe"' & '" "' & $dest & '" /Y',@TempDir) Next EndIf But this attempt just loops the coping of destination 1. Just to make it clear the goal of my script is to read all the IP adresses of the INI file and copy the chosen files from every location to a local directory. I cant figure out how the array thing work, even though been searching through forums and help file, so i really hope you can help me.. Link to comment Share on other sites More sharing options...
dabus Posted August 17, 2006 Share Posted August 17, 2006 (edited) $source = IniRead("C:\Backup\backup.ini", "1", "IP","error") $dest = "C:\backup" $var = IniReadSectionNames("C:\Backup\backup.ini") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0] $copy = RunWait(@ComSpec & ' /c xcopy "'& $source & '"\file.exe"' & '" "' & $dest & '" /Y',@TempDir) Next EndIf Just don't mess with $var if you still use it. Edited August 17, 2006 by dabus Link to comment Share on other sites More sharing options...
Danny35d Posted August 17, 2006 Share Posted August 17, 2006 (edited) This should work for you....$dest = "C:\backup" $var = IniReadSectionNames("C:\Backup\backup.ini") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0] $source = IniRead("C:\Backup\backup.ini", $var[$i], "IP","error") If $source <> 'error' Then RunWait(@ComSpec & ' /c xcopy "'& $source & '"\file.exe"' & '" "' & $dest & '" /Y',@TempDir) EndIf Next EndIfEdit: Fixed TypoI will replace this line $var = RunWait(@ComSpec & ' /c xcopy "'& $source & '"\file.exe"' & '" "' & $dest & '" /Y',@TempDir)for this one FileCopy($source & '\file.exe', $dest, 9) Edited August 17, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now