Solved Make a batch file lauch a batch file in %systemdrive%.

February 1, 2012 at 06:20:28
Specs: Windows 7
I'm having some trouble getting my batch files to launch correctly.

I have a batch file that copies other batch files and folder to "%systemdrive%", at the end it's supposed to launch a batch file in a folder like so "%systemdrive%"\MCBackup\LIT\Run.bat
It opens up a cmd prompt window but doesn't execute the batch file. I have several others (roughly 7 or so) that are doing the same thing.

copy of the batch files listen below.

Initial_Run.bat

@Echo .
@Echo .
@Echo .
@Echo .
@Echo .
@Echo .
@Echo This will copy the files to the Correct locations for this process.
@Echo .
@Echo .
@Echo .
@Echo .
@echo .
@Echo THIS IS NOT BACKING UP THE MINECRAFT FILES AT THIS TIME!
@Echo .
@Echo .
@Echo .
@Echo .
@Echo .
@echo .
@Echo This will automatically launch the backup process. I recommend you allow it to backup your files at this time.
@echo .
@echo .
@echo .
@echo .
pause

md "%systemdrive%"\MCBackup\BackedFiles\

md "%systemdrive%"\MCBackup\BackedFiles\backups\

md "%systemdrive%"\MCBackup\RestoreFiles\

md "%systemdrive%"\MCBackup\LIT\

md "%systemdrive%"\MCBackup\MCTP\

md "%systemdrive%"\MCBackup\MCTP\TPBackups\

Copy LIT\* "%systemdrive%"\MCBackup\LIT\

Copy BackedFiles\ "%systemdrive%"\MCBackup\BackedFiles\

Copy RestoreFiles\* "%systemdrive%"\MCBackup\RestoreFiles\

copy MCTP\* "%systemdrive%"\MCBackup\MCTP\*


md "%systemdrive%"\MCBackup\MJar

md "%systemdrive%"\MCBackup\Mjar\Rest

Copy MJar\* "%systemdrive%"\MCBackup\MJar\

Copy Initial_Run.bat "%systemdrive%"\MCBackup\

attrib -h Backup.bat
attrib -h BackupBin.bat
attrib -h Restore.bat
attrib -h ClassEditor.bat
attrib -h SavesBackup.bat
attrib -h TexturePack.bat

copy Backup.bat "%systemdrive%"\MCBackup\

Copy BackupBin.bat "%systemdrive%"\MCBackup\

Copy Restore.bat "%systemdrive%"\MCBackup\

Copy ClassEditor.bat "%systemdrive%"\MCBackup\

copy SavesBackup.bat "%systemdrive%"\MCBackup\

copy TexturePack.bat "%systemdrive%"\MCbackup\


attrib +h "%systemdrive%"\MCbackup\Initial_run.bat

md "%systemdrive%"\MCBackup\WS\

md "%systemdrive%"\MCBackup\WS\Worlds\

Copy WS\ "%systemdrive%"\MCBackup\WS\

del /s /q BackedFiles\*
del /s /q LIT\*
del /s /q MJar\*
del /s /q RestoreFiles\*
del /s /q WS\*
del /s /q MCTP\*
del /s /q Backup.bat
del /s /q BackupBin.bat
del /s /q Restore.bat
del /s /q ClassEditor.bat
del /s /q SavesBackup.bat
del /s /q TexturePack.bat

rmdir Backedfiles\
rmdir LIT\
rmdir RestoreFiles\
rmdir WS\
rmdir MJar\
rmdir MCTP\

start "%systemdrive%"\MCBackup\

Cd "%systemdrive%"\MCBackup\LIT\
Start "%systemdrive%"\MCBackup\LIT\Run.bat
del /s /q Initial_Run.bat
exit

Run.bat

@Echo .
@Echo .
@Echo .
@Echo .
@Echo This set of batch files was written for Windows
@Echo They will make a back up of your minecraft.jar file and
@Echo the entire \bin\ folder. Additionally they will back up
@echo your saved games. The restore feature will only work after @echo you've successfully backed up the files.
@Echo .
@Echo .
@Echo .
@Echo .
@Echo I made this so I wouldn't have to constantly back up my minecraft.jar manually
@Echo Before adding a MOD that may or may not work. This simplifies
@Echo The process so that even new people to MODDING can enjoy it.
@Echo .
@Echo .
@Echo . 
@Echo .
@Echo . 
@Echo To initialize the back up process please hit the space bar.
pause

start "%systemdrive%"\MCBackup\BackedFiles\Backup1.bat
exit

What have I done wrong?


See More: Make a batch file lauch a batch file in %systemdrive%.

Report •

✔ Best Answer
February 1, 2012 at 12:01:54
the exit was used simply because the user wouldn't need to know what happened
CMD will stay up if the script was started within CMD. If the script was launched from the GUI, CMD will close when the script ends. This is the desired behavior 98% of the time, so don't go mucking that up.

The command start "%systemdrive"%\MCBackup\LIT\Run.bat launches Run.bat if typed in cmd, just not from the batch file.
Incorrect. It launches a new instance of CMD with the title of "%systemdrive%\MCBackup\LIT\Run.bat". I still suggest you read up on the START command.

Your problem is with the quotes. Remove them.

How To Ask Questions The Smart Way



#1
February 1, 2012 at 06:28:30
Also, It was working fine when I was just using C:\MCBackup\LIT\Run.bat but not since adding "%systemdrive%" to the batch file.

Report •

#2
February 1, 2012 at 07:02:18
What have I done wrong?
Well, for starters, you exit at the end of the script. Let CMD handle if it should quit or not; it's the user's decision, not yours.

Also, I'd read up on START. (Although I'm not sure why you're even using START.)

How To Ask Questions The Smart Way


Report •

#3
February 1, 2012 at 08:55:38
I posted 2 different batch files up there. Hence why the "exit" looks as though it's in the middle. I make it exit because it was doing everything it was supposed to do correctly, up until the end at Start "%systemdrive%"\MCBackup\LIT\Run.bat

Run.bat is just a prompt that has information about the next batch file which also doesn't launch start "%systemdrive%"\MCBackup\BackedFiles\Backup1.bat

Those batch files launch if i use C:\ instead of "%systemdrive%"


This is what I need help with.


Report •

Related Solutions

#4
February 1, 2012 at 09:08:24
You don't read my post and accuse me of not reading yours. (I did.) This makes me sad.

How To Ask Questions The Smart Way


Report •

#5
February 1, 2012 at 09:34:25
I wasn't accusing you of not reading it, I just assumed you thought I had posted one big batch file. My apologies for that.

I tried leaving off start and it launched correctly, however not in the way I would like it to. I would like for it to launch in an entirely new window, as it does when I use "Start C:\MCBackup\LIT\Run.bat" instead of "%systemdrive%"\MCBackup\LIT\Run.bat".

Again, the exit was used simply because the user wouldn't need to know what happened because the prompt launches the new folder for all this as well as the new window Run.bat before closing itself.


Report •

#6
February 1, 2012 at 09:38:46
A quick insight, The command start "%systemdrive"%\MCBackup\LIT\Run.bat launches Run.bat if typed in cmd, just not from the batch file.

Report •

#7
February 1, 2012 at 12:01:54
✔ Best Answer
the exit was used simply because the user wouldn't need to know what happened
CMD will stay up if the script was started within CMD. If the script was launched from the GUI, CMD will close when the script ends. This is the desired behavior 98% of the time, so don't go mucking that up.

The command start "%systemdrive"%\MCBackup\LIT\Run.bat launches Run.bat if typed in cmd, just not from the batch file.
Incorrect. It launches a new instance of CMD with the title of "%systemdrive%\MCBackup\LIT\Run.bat". I still suggest you read up on the START command.

Your problem is with the quotes. Remove them.

How To Ask Questions The Smart Way


Report •

#8
February 2, 2012 at 15:35:08
Thanks for the advice. I rewrote the batch files to simple load from one to another without the start command. Seems more fluid this way compared to the previous way.

I'm working on making a GUI in Visual Basic that will launch the batch files. Maybe later on transferring it all to Visual Basic.


Report •

Ask Question