Jump to content

is this possible with auto it


Recommended Posts

hello everyone

i am new to this forum and autoit in general, i have been using an autoit script for a couple of years created by a user but now that script does not work but thats another post all together for i have a separate question now.

i have a home network set up at home and i am wondering if one can create a script that does the following and to make it easy it might be better to create two scripts

the first script would run on a remote pc on the network but i guess being on a network wouldn't make a difference for this one since its running on the pc itself.

script one

is set to run at a specific time, maybe once a week at a set time and when that time hits it checks to see if a program is running, if it is running it can be set to terminate the program, no need to worry about saving the open file and such since the second script is goign to overwrite and update the files.

the second script is the more complex one

the script would at a certain time (like the script above) copy folders and files over from one pc on a network to another network location. it would have to be able to tell it to merge with the folder there and then to skip anything already in the folders (in the copy box you can check the do this for the next xxx conflicts and i want it to chose do not copy, but that is only for the folders which right now is only two folders but each has about 3500 images in them, the second part of it is to copy a file (in this case a database file) to the other pc and overwrite the file if it exists on the other pc (which most likely it is going to b e there), then after it does this for the networked pc it moves onto the next networked pc, and so on until its updated all them on my network.

Link to comment
Share on other sites

i've been playing with this. while at this point fixing the other script (its another post) is beyond me, i am bound to figure this one

i've done some searching and it appears copying is rather straight forward yet i can't seem to get it to work

i first started just by trying to copy one file from one drive to another, then i'd figure i'd work to the folders, then i'd get it to do this to the remote pc's.

but i have to be doing something wrong.

i've been trying different examples

but get unable to parse line

or missing separator

Link to comment
Share on other sites

i even opened the script from the help file and just changed the file name and location and i am not getting anything. no error's either but nothing is being copied

with the script below, i'm getting it to work to a point. i can get it to copy anything from the d thats a mvc file to the c drives foo folder

however if i try to get it to copy a specficic mvc file, for example in this case one called test.mvc it don't do anything, there's no error but nothing is copied over.

i replaced the *.mvc with test.mvc and i tried the foo\*.* , foo\test.mvc, and just foo\ with no luck

FileCopy("D:\*.mvc", "C:\foo\*.*")

; Method to copy a folder (with its contents)

DirCreate("C:\new")

FileCopy("C:\old\*.*", "C:\new\")

FileCopy("C:\Temp\*.txt", "C:\Temp\TxtFiles\", 8)

; RIGHT - 'TxtFiles' is now the target directory and the file names are given by the source names

FileCopy("C:\Temp\*.txt", "C:\Temp\TxtFiles\", 9) ; Flag = 1 + 8 (overwrite + create target directory structure)

; Copy the txt-files from source to target and overwrite target files with same name

Link to comment
Share on other sites

ok another update

i am getting hte hang of this but the prior imdb script is still way beyond my ability.

so anyways.

i now have the script so it will copy two folders and the mvc files to another location, even to another pc on the network.

so a lot of this script is done but there is two things i would like to try to get worked out.

one how on the file copy why can't i copy just the single (in my case test.mvc file, it won't work only the *.mvc which moves all of them), i know an easy solution for me is to only have one there but i would like to know what i've done wrong.

second, how can i get the script to pop open a txt file or whatever saying its been ran and had no issues or even just that it been ran with the time and date, if possible of each pc that gets copied files.

i found that i can compile the program to an exe file and then set it in windows scheduler to run whenever i want.

Link to comment
Share on other sites

ok an update

i found a way to termiante the program for one script and how to compile them to exe's and windows scheduler can take care of the scheduling.

so its really just down to the copying script which i have working to a point, its doing almost what i want.

as mentioned in the prior post i can't get it to copy just one mvc file, it seems no matter what i try if i put in for just the one file i get nothing.

other than that some kind of notice would be great to let me know it ran and especially if there was any errors.

just curious but what happens if you have it set to copy multiple folders and files to multiple pc's and say the first pc for some reason is not on, will it just continue onto the next line of the script or will it pause and error out becasue it could not complete something it already had, and is there a way around that?

Link to comment
Share on other sites

Wow. lots of information ... lacking a bit on question marks though. :mellow:

... how can i get the script to pop open a txt file or whatever saying its been ran and had no issues or ...

For small message text Msgbox() is a start.

... i can't get it to copy just one mvc file, ...

Show the code lines your using for your copy process and the data that you put in it.

- If your editor supports it (see Scite4AutoIt3 if not) use ConsoleWrite() in the script to print variable data into the editors console output pane.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

thanks for the replies

i'll first address the suggestion of using software like windows live, dropbox, etc. I am not sure about the others but dropbox would require me to install it on every pc and then each pc synch will take up space on dropbox and i use dropbox for other reasons and can't afford the use of space on it and if i create drop box accounts for each pc then i am in violation.

the other problem is i don't really want most of this information past my home network. i have the script almost running correctly.

second thanks for the help with the message box i just started looking at autoit last night and i really could use a listing of what does what in a convenient place, i know it has help files but unless i know what to look at then it confusions me. plus so far i'm not having luck with another post with a script that grabs info from well really your clipboard and imports it into a database program, i was trying to go through it and figure it out but i had no idea what most of it was even doing. but that is another post if anyone interested, hahahaha

anyway here is the script i have that not running correctly (its the test one that does the copying all on one pc and not the network, i have all that worked out.

what i can't seem to get right is how to copy the single file over, as you can see the filecopy right now says *.mvc as that was the only way i got it to copy over the mvc file, but it does all of them. when i specify the exact file in my test case was test.mvc nothing happens, i found the problem with it. i had two . so the file was not being found because of that.

now i do have another question. it runs and copies the stuff over and now will only copy the one specific mvc file and pops up a message box that its completed, this is all basic i know, but i tested this by seeing what happens if i removed the single file it was to copy over, it ran and the message box popped up but the file didn't copy over (because i moved it) how do i get the message box to indicate that the file didn't copy over, perhaps i can expand on this.

the folders and file i am copying over are always going to be on the other pc's. however the folder copies are set to not overwrite the file if its there where the mvc file is set to overwrite, how can i get a listing as a txt file or message box of what was updated, probalby a file

DirCopy("D:\images", "C:\foo\images", 8)
DirCopy("D:\thumbnails", "C:\foo\thumbnails", 8)
FileCopy("D:\test.mvc", "C:\foo\")
MsgBox(1,"transfer complete", "completed", 0)
Link to comment
Share on other sites

ok want to update some on this.

i was looking into a progress bar but its probably more work than whats needed especially since most of the time these will be running at night when no one is awake.

it would be nice if i could get it to create a txt file on what was copies over (since its set to not overwrite anything already there that should give me a list of what was updated plus the file copy is set to overwrite, would be nice to get a txt file with the date of the update, my problem is besides not being able to figure out how to do this, is i would love to have one file created at the end but list what was updated on each copy, ie i have 4 machines with one being the source and the other 3 eventually getting copied over, so the text file would list say machine 2 and what was updated, machine 3 and what was updated, etc, in theory these update lists should be the same unlesss one machine was not running during a scheduled update.

the next thing and this reflects back to the message box

i got it to work, then i wanted to test something so i added a second copy location(eventually every location will get the same files copied), and while it worked, i seemed after the first copies it went to the message box and opened it up, and stopped until i hit ok.

i want the message boxes so i know if something was updated, but is it possible say to run the script and have it copy the stuff to multiple pc's (again most of this will be done while most everyone is sleeping or at work) and say when i get back to the pc i'll have multiple message popups letting me know each pc was copied too.

below is the sample script i am using to test.

DirCopy("D:\images", "C:\foo\images", 0)
DirCopy("D:\thumbnails", "C:\foo\thumbnails", 0)
FileCopy("D:\test.mvc", "C:\foo\", 1)
MsgBox(1,"transfer", "completed", 0)
FileCopy("D:\test.mvc", "\\stargate\d", 1)
MsgBox(1,"transfer", "completed on stargate", 0)
Edited by rgs80074
Link to comment
Share on other sites

second thanks for the help with the message box i just started looking at autoit last night and i really could use a listing of what does what in a convenient place, i know it has help files but unless i know what to look at then it confusions me.

Read everything under "Function Reference" and "User Defined Function Reference" several times a day, that's the only way to get used to it.

As for the message boxes for status update, msgbox block the script so maybe output the command results to a text file or something?

Edited by PowerCat
Link to comment
Share on other sites

i just started looking at autoit last night

I'm getting the feeling the same applies to coding in general to. (You might like to try out 'Welcome to AutoIt 1-2-3' for getting more familiar with AutoIt ... and, well, not to sure here, some coding basics in general.

i really could use a listing of what does what in a convenient place, i know it has help files but unless i know what to look at then it confusions me.

Assuming that's because English is not your strong point (Otherwise the manual IS the place to go). You could try to use the online documentation pages(wiki) together with some browser auto translator. But that's not really going to help with searching I imagine. (So you kinda stuck with English, unless your better in one of these (Unofficial forums) languages. As they might have created translated version of the manual.)

Some code that should help you with some of your questions.

- take note of the fact that you can click on some of the commands/functions to jump to the relative documentation on them.

Local $sMessageString = '... Filecopy test ...' & @CRLF
If FileCopy("D:\test.mvc", "C:\foo\") Then
    $sMessageString &= "FileCopy() succesfull."
Else
    $sMessageString &= "FileCopy() Failed."
EndIf
MsgBox(1,"MsgBox", $sMessageString)
Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

no English is my only language, everything assumes a person has a lvl of knowledge that i think many of us don't have, its fine and dandy having the stuff there but if a person is not aware of where it is or how to find it, it causes problems. i've used google to do a lot of searching but so much of the scripts have things in them i just can't figure out. i assume from your snippet it should basically say if the file copied right then it was successful and would create the message box otherwise it creates a failed file copy, but since i am copying two folders and one file to multiple locations (in this sample script i posted it was just two places and the second was just a single file copy but eventually its going to copy the other folders as well.

the manual is what i've been looking at but i just don't understand most of it, i don't understand coding or programming in general and it seems half of the stuff in the scripts are not needed but i assume they have to be or why would people put them in and its like the script i am looking to fix that copies stuff from the clipboard and imports them into a program, there seems to be tons of info in it and i can't figure out what most of it does, i tried going through the script but half of the stuff i don't see references too anywhere.

i feel like i made some strides last night in getting to where i am now, i could leave everything as is and it probably would work just fine,

and if a message box stops the script then yes its not what i want a text file would be better

thanks for the code i'll give it a test, but that just proves my point, i don't get where the local, if, then , else and such is for but i'm willing to learn, i just don't have the free time i could use to learn this stuff correctly and who knows when i will be to the point to fix that script i need fixing and by not having it working thats causing me to waste a lot of time elsewhere. (not these scripts but the one from my other post that was created by hero88)

i'll play with the code but so far i get a failed, when i run the script the first thing that happens is a complete msg box and then a failed message, perhaps i did something wrong i don't know

so to summarize right now with the above script with a bit more editing and such i can get the script to copy the folders and files to every networked pc and i could get it to display a final message box at the end and it would work for me and do what i wanted for the main part, what i don't get would be a message that it completed on each pc and or a text file showing me what was updated but i am willing to put some time into this stuff until i get it right

Link to comment
Share on other sites

You're absolutely right, man. The help file doesn't take you by the hand. Basically you have to look at sample code and read up on the different commands and functions to figure out what's what.

You say you don't know what the whole "if then else" is, so look it up in the help file and then try to make some samples for yourself.

Make some msgboxes that'll popup depending on some conditions until you feel comfortable with if then else, cause that's a base of programming!!

Link to comment
Share on other sites

Think some 'Programming Basics'(requires Java 1.4 or later) upgrade is needed here.

- This is just one I found. Look/Google around for more.

---

lol

Program

Step 1
    Forget Everything

Step 2
    I Forgot
Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

thanks for the programing basic

i'll take a look at that when i can.

as for the message box i don't think thats what i am looking for. if its going to stop the script from completing then i need to have a text file set up to be created and opened when its done.

perhaps what i should do is finish the script so it works to the point that i can use it without the bells and whistles so to speak, i know how to set it up so it does the copying over i just get no confirmation it happened or if anything was wrong and what was updated.

Link to comment
Share on other sites

i went through the programing basics

still at a loss.

right now i can get the script to copy the two folders and file over to multiple locations, it does not over write any of the files in the folder and does overwrite the single file being copied.

the fact i can get it to do this across the network to multiple pc's is 90% of what i wanted.

i was just trying to get a couple of bells and whistles inserted into them but i just don't understand it, i look at the functions and such but don't have any idea where to start.

i was thinking of a progress bar but after really thinking about it, its not really needed since its going to be running when either i am sleeping or at work.

i liked the message box idea but since it pauses the script my theory that i'd come back and have multiple boxes open saying transfer complete on pc 1, transfer complete on pc 2 wasn't going to happen

sure i'd love to be able to get a summery at the end of everything or a text file at the end or after each transfer that lets me know

the transfer to each pc was completed and the number of files that was copied over, i think originally i wanted a listing but if for some reason the stuff was deleted off the receiving pc before that woudl be over 10k in file listings. so a total number of files copied and if it would be noted that single file that gets copied was over written would be a bonus.

but as of right now i need to get this working as fast as possible and i spent many hours over the last couple of days i had off now i am real far behind on other things. i will say i made some progress on the scripts at css and xls editing but nothing is the way i want it completely, they are close but not exactly how i want it.

i have one script on this that will close the program so the file can be over written.

can't figure out how to create a script that will see if the program is open and if it is have it save the file and exit, it would be nice but its only a just in case as i usually close the program before heading to bed or work but even if i don't i've at least saved the file.

so if you all can help me in finishing the copying script with the outputted text file as indicated that would be great.

i still plan on learning what i can but my time is limited and i can't spend the amount of time i had over the last couple of days repeatedly, i just have way to much to do, i think most people learn this stuff little by little so trying to get caught up all at once probably rarely happens but i figure little by little i'll learn.

Link to comment
Share on other sites

I too have a hard time following just what you are saying.

For copying files, you can assign a varaiable to the filecopy command and then use the return value to determin if the copy was successful or not.

$filename1 = "source.txt"
$filename2 = "destination.txt"

$return = filecopy($filename1,$filename2,9) ;create destination folder and overwrite file if it exists.
; filecopy success returns 1.   filecopy failure returns 0
if $return = 0 Then ;failed
    filewriteline("LogRecord.txt","File " & $filename1 & " not copied.")
Else ;success
    filewriteline("LogRecord.txt","File " & $filename1 & " successfully copied as " & $filename2 & ".")
EndIf

The above example is OK for a few files, but not the best way if you are doing a lot of files. Instead, I would open the LogRecord.txt file for writing, then write to it each time, then close it at the end.

Link to comment
Share on other sites

for the logrecord.txt

that sounds like what i would want except for the closing it, i would assume its possible to leave it open after the time it was written, perhaps saving the txt file as the current date.

my current code as it stands at this moment, this is not the final as i know how to add and change what is being copied and to where as this will change as more pc's get put online on the home network

DirCopy("D:\images", "C:\foo\images", 0)
DirCopy("D:\thumbnails", "C:\foo\thumbnails", 0)
FileCopy("D:\test.mvc", "C:\foo\", 1)
MsgBox(1,"transfer", "completed", 0)
FileCopy("D:\test.mvc", "\\stargate\d", 1)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...