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 exitRun.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 exitWhat have I done wrong?
Also, It was working fine when I was just using C:\MCBackup\LIT\Run.bat but not since adding "%systemdrive%" to the batch file.
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.)
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.
You don't read my post and accuse me of not reading yours. (I did.) This makes me sad.
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.
A quick insight, The command start "%systemdrive"%\MCBackup\LIT\Run.bat launches Run.bat if typed in cmd, just not from the batch file.
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.
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.
| « Make batch file always co... | Batch files - nested loop » |