chiners_68 Posted December 10, 2007 Share Posted December 10, 2007 (edited) Hi All, Ive wrote this quick script which works from in windows. ive got it setup as a startup script in active directory but its not working. is there smoething im missing or that im doing wrong? can you copy files down to a machine at startup? the files to be copied down are in the same folder as the autoit exe that is executed. If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy("EBC2001.BMP", @WindowsDir, 1) Endif Endif If FileExists(@WindowsDir & "\EBC Stars.scr") then If FileGetSize(@WindowsDir & "\EBC Stars.scr") < 409600 Then FileCopy("EBC Stars.scr", @WindowsDir, 1) Endif Endif Filecopy("BakScrLOG.txt", "c:\", 1) the txt file isnt even copying down to c:\ Edited December 10, 2007 by chiners_68 Link to comment Share on other sites More sharing options...
erebus Posted December 10, 2007 Share Posted December 10, 2007 When performing FileCopy() be sure to use full paths like FileCopy("C:\Folder\EBC2001.BMP", @WindowsDir, 1) or like FileCopy(@ScriptDir & "\EBC2001.BMP", @WindowsDir, 1) Link to comment Share on other sites More sharing options...
mikiutama Posted December 10, 2007 Share Posted December 10, 2007 file cannot be copied on top of itself, that's why you have errors.. @WindowsDir & "\EBC Stars.scr" << if exist then FileCopy(@WindowsDir & "\EBC Stars.scr"..... >>will produce error since same location and same filename.... need to rename or delete as below... If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy("EBC2001.BMP", @TempDir, 1) FileDelete(@WindowsDir & "\EBC2001.BMP") FileCopy(@TempDir & "\EBC2001.BMP", @WindowsDir, 1) FileDelete(@TempDir & "\EBC2001.BMP") Endif Endif Filecopy("BakScrLOG.txt", "c:\", 1) where is BakScrLOG.txt located? same folder as script or created new log file? Link to comment Share on other sites More sharing options...
chiners_68 Posted December 10, 2007 Author Share Posted December 10, 2007 erebus, is this macro necessary? @ScriptDir, it seems to work in windows with just the file name. mikiutama, BakScrLOG.txt is in same location as compiled script. This file dosent pre exisit in c:\ but dose not get copied down to c:\ I cant see a problem with overwriting the exisitnig files as it works when in windows. Link to comment Share on other sites More sharing options...
picaxe Posted December 10, 2007 Share Posted December 10, 2007 When performing FileCopy() be sure to use full paths like FileCopy("C:\Folder\EBC2001.BMP", @WindowsDir, 1) or like FileCopy(@ScriptDir & "\EBC2001.BMP", @WindowsDir, 1)Have you tried erebus's suggestion. Login credentials may be different when it is run as "startup script in active directory" Link to comment Share on other sites More sharing options...
chiners_68 Posted December 10, 2007 Author Share Posted December 10, 2007 ill try Erebus's sugestion. ive tried mikiutama sugestion If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy("EBC2001.BMP", @TempDir, 1) FileDelete(@WindowsDir & "\EBC2001.BMP") FileCopy(@TempDir & "\EBC2001.BMP", @WindowsDir, 1) FileDelete(@TempDir & "\EBC2001.BMP") Endif Endif Filecopy("BakScrLOG.txt", "c:\", 1) All that worked was deleting the file. Both the bmp file & simple text file do not get copied down. maybe erebus's adition will help that bit. Link to comment Share on other sites More sharing options...
chiners_68 Posted December 10, 2007 Author Share Posted December 10, 2007 Erebus's idea didsnt work. If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy(@ScriptDir & "EBC2001.BMP", @TempDir, 1) FileDelete(@WindowsDir & "\EBC2001.BMP") FileCopy(@TempDir & "\EBC2001.BMP", @WindowsDir, 1) FileDelete(@TempDir & "\EBC2001.BMP") Endif Endif Filecopy(@ScriptDir & "BakScrLOG.txt", "c:\", 1) When i put in the full paths the txt file copied down ok. If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy("\\server\fileshare\EBC2001.BMP", @TempDir, 1) FileDelete(@WindowsDir & "\EBC2001.BMP") FileCopy(@TempDir & "\EBC2001.BMP", @WindowsDir, 1) FileDelete(@TempDir & "\EBC2001.BMP") Endif Endif Filecopy("\\server\fileshare\BakScrLOG.txt", "c:\", 1) Link to comment Share on other sites More sharing options...
chiners_68 Posted December 10, 2007 Author Share Posted December 10, 2007 ive gone back to my original script which now works fine. So for Windows startup scripts you need to use UNC paths as macros do not work for @scriptDir If FileExists(@WindowsDir & "\EBC2001.BMP") then If FileGetSize(@WindowsDir & "\EBC2001.BMP") < 1572864 Then FileCopy("\\server\filename\EBC2001.BMP", @WindowsDir, 1) Endif Endif If FileExists(@WindowsDir & "\EBC Stars.scr") then If FileGetSize(@WindowsDir & "\EBC Stars.scr") < 409600 Then FileCopy(("\\server\filename\EBC Stars.scr", @WindowsDir, 1) Endif Endif Filecopy("\\server\filename\BakScrLOG.txt", "c:\", 1) Link to comment Share on other sites More sharing options...
mikiutama Posted December 10, 2007 Share Posted December 10, 2007 you should mention in your first post that you gonna copy those files over a network.....!! Link to comment Share on other sites More sharing options...
chiners_68 Posted December 11, 2007 Author Share Posted December 11, 2007 mikiutama, bit late now. Didnt relise it would make a difference. 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