Sign in to follow this  
Followers 0
chiners_68

Asistance with script.

10 posts in this topic

#1 ·  Posted (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 by chiners_68

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

you should mention in your first post that you gonna copy those files over a network.....!!

Share this post


Link to post
Share on other sites

mikiutama,

bit late now. Didnt relise it would make a difference.

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  
Followers 0