1.

Solve : starting second batch from 1st not working...?

Answer»

hello everyone,

I'm still plugging away in batchland, and am confused about another issue. I realized that the reason I couldn't get a folder to delete at the end of my batch file was because the folder is the one that contains the batch...and the machine isn't going to allow me to delete a folder it is currently USING...

therefore, my idea was to make a second batch file that is accessed from a different directory. I read about the 'call' command, but that seemed like it would access another batch but return to the first, so that wouldn't really help me.

I also read that you could execute a batch from a batch by just putting in the path and name of the second batch. Using this method, I am getting the "the process cannot access the file because it is being used by another process" error.

So, I guess the first batch has not "ended" in the eyes of the machine. I can understand that, I suppose, as it doesn't get to SEE any "exit" command in the first batch file. I've got one in there, of course, but it's after the call to the second batch. I've even tried having the second batch file and folder pre-exist on my harddrive, but still get the error.

any ideas? Thanks in advance for any assistance.
is this what you WANT?

Code: [Select]:: %folder% should be the name of the folder you are deleting

cd..
echo ping -w 1 1.1.1.1>>secondbatch.bat
echo del %folder%>>secondbatch.bat
start secondbatch.bat
exit

thanks for the response! I appreciate it.

I HATE to show my ignorance, but I'm not sure if that's what I want, lol. I am pretty basic in my dos understanding and don't really understand what the ping part of the code or the ">>" means.

Sorry

Would that work for a situation where i've got an exe that creats a temp folder and then extracts a local website (OFFLINE content) as well as a shortcut to the site, and the batch into it? After extraction, the batch runs.

The batch moves the offline website folder to the root of c, and then moves the shortcut to the site to the desktop. The last thing I need to happen is to delete the tmp folder that the stuff originally extracted to.

As i said in my earlier post, I couldn't get the tmp folder to delete and i figured it was because the batch is running from the same folder, so I created the 2nd batch which exists solely to delete the temp folder.

again, I appreciate the response and apologize for my ignorance.what the code does is it can be added into your first batch that inside of the folder and it will make a second batch outside of the folder, close the first one and delete the folder. The ping will make it wait to make sure that the first batch is closed before the second one deletes it.thank you for the explanation!

I will give this a try.



Discussion

No Comment Found