1.

Solve : Edit Autoexec.bat Through a .bat??

Answer»

I feel totally retarded.

I am working on a project and have been for a couple days now.

I have most of everything I need done

I just need to be able to edit the autoexec.bat somehow through a different .bat file

And I do have a few sub questions

#1 When running a .bat on startup, does it run before anything else, or after, or in no set order

#2 I dont remember where I saw it on the site, but I remember that there was some way to skip files/folders from being delted, I just dont remember what that was.

#3 How do you move files


I am running on the windows XP OS

Sorry about all the questions. I feel retarded posting for help so soon, I feel like a leecher
What are you REALLY trying to accomplish?sounds like he's trying to remodulate the majiggery agitator on the combustive flatulater while a unicorn sips fairy juice out of a popper.Thank you for your kind words of advice, This was totally worth it.why do you need to edit it through a different bat file?
and could you elaborate on points 2 and 3 please?Is this a homework assignment? Hopefully not, so here are some hints:

1) If you are talking about the AUTOEXEC.BAT getting run during MS-DOS boot, I think it loads in this order: IO.SYS, CONFIG.SYS, COMMAND.COM, AUTOEXEC.BAT. If you are talking about the order of executing .bat vs .com vs .exe, I think it goes in order of .COM then .EXE then .BAT for the same file name before the extension.

2) You might be talking about DEL /P that will prompt before deleting files so you can skip files if you don't want them deleted.

3) The MOVE command.QUOTE from: shiro on May 24, 2007, 06:05:25 PM

I am running on the windows XP OS

On XP machines, the autoexec.bat file has morphed into the autoexec.nt file. It is used (along with the config.nt file) to initialize the command prompt environment (cmd.exe)

Windows initializes from values in the registry.

Thank you so MUCH Guru Gary, that actually did help.

Sorry about my response it was just late at night and I took reaper's response pretty harsh.

But actually this is a bet from a friend. He made some program or whatever that basically just creates a blank file on startup. and he bet me $20 that I couldn't make a program to delete it on startup.

It sounds nerdy, mainly because it IS

but I learned about DOS and hopefully getting $20.

Question 3 was just for my own info.

It really was a interesting experience and I might find a use for bat files LATER on.

But SERIOUSLY thank you seriously now...nobody answered..how to edit a another .bat file with a .bat file...a I would really like to know...Do you want to edit the entire thing or just add something at the end or completely change the file you are editing. There are two ways I know how to do this.

Outline:
delete the current file
create a new file in the same location with an edited code

Is that more or less what you (two) are looking for?Quote from: adikid on May 26, 2007, 04:24:02 AM
seriously now...nobody answered..how to edit a another .bat file with a .bat file...a I would really like to know...

Hints are appropriate for a true learner. You don't want to just see how the magic trick is done, do you?btw my COMMENT was possibly a bit misinterpreted... i do actually enjoy doing things like this and i would like to know about this particular subject aswell

It is not easy to edit / replace strings in batch. You can use
SET := to do string replacement, but there are several characters that will confuse that SET command. So basically there is no robust reliable way to edit a .BAT file with another .BAT file (without lots and lots of work and error checking).

Here is a simple example:
Code: [Select]@echo off
set String=Hello World
echo %String%
set String=%String:World=Reaper%
echo %String%
So using that example, you could get each line out of a file (with a FOR /F loop) and replace the contents that you are looking for with new values using the SET := but you will need to do lots of error checking as there are lots of characters you will need to work around.

Is that what you were looking for?


Discussion

No Comment Found