This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Stormkrow's profile picture

[Question][Error] Auto copy files on disk through Startup

Started by Stormkrow, 05 July 2012 - 06:43 AM
Stormkrow #1
Posted 05 July 2012 - 08:43 AM
Ive been trying to get a program on a disk to run as startup so that when the PC boots it loads automatically and is saved so that all reboots afterwards will use the program from the diskdrive. Thus far i've gotten the disk to run at startup but everytime i get the folder to copy and reboot the computer it gives the error :

startup:1:file exists

The contents are all copied but the program cant be run? The code i use to copy is:
fs.copy("disk/startup","startup")

What am i doing wrong?
KaoS #2
Posted 05 July 2012 - 09:01 AM
you need to delete the existing startup file on the computer and then copy. try this


if fs.exists("startup") then fs.delete("startup") end
fs.copy("disk/startupfile","startup")

that will remove the existing one if it is there and re-copy it. I could not test that code so there is probably a spelling error or something
another thing you need to know is that it will not read the local startup if there is a disk startup file so you have to remove the disk first
also. do not copy the disk's startup file. you need to write a separate file for the computer to use. let me show you what I mean

if you have the startup file you want to use:



fs.copy("disk/startup","startup")
--all of the rest of the startup code

then when you first run the disk it will work fine, it will copy the startup file across and then run the rest of the startup code, the problem is that YOU STILL HAVE THE COPY TAG IN THE PC STARTUP so if you take that disk out and insert a new one the pc will try to copy disk/startup across
Stormkrow #3
Posted 05 July 2012 - 09:15 AM
Ok thanks ill try this out :P/>/>
KaoS #4
Posted 05 July 2012 - 10:16 AM
Awesome. let us know if you have any problems