|
Answer» Ok, so I need to make a batch file that calls a batch from the C:\, then goes back to the file where the batch started, and calls and/or starts another batch. I have tried a couple of codes: (a.bat is in the C:\, b.bat is in the same file as the batch being run)Code: [SELECT]set 1=%CD% pause>nul cd\ call a.bat cd "1" call b.bat pause>nulCode: [Select]@echo off set 1="%~dp0" cd\ call a.bat cd "1" call b.bat pause>nulCode: [Select]set choice="%CD%" set /p choice="%CD%">nul if '%choice%'=='%CD%' goto :1 :1 cd\ call a.bat cd "%choice%" call b.bat pause>nul but none of the above seem to work. So I guess what I'm asking is, Is this possible? and if so, what would the correct code be? Thanks!You're making this much harder then it has to be. Your first example was the easiest to fix.
Code: [Select]set 1=%CD% pause>nul cd\ call a.bat cd %1% call b.bat pause>nul
The KISS METHOD would be:
Code: [Select]call \a.bat call b.bat
I don't recommend using numerics as the target of a set command. They are too easily CONFUSED with command line arguments. Batch code is cryptic enough.
Someday, someone will have to explain pause>nul to me.
Sidewinder, happy to oblige
Pause does 2 THINGS, waits for a keypress and DISPLAYS Press any key to continue ....
Redirecting the output of Pause means it will still wait for a keypress, but the message will not appear, it is usually accompanied by a customised message using Echo
...... Echo Processing complete, press a key to exit Pause>Nul
GrahamQuote Sidewinder, happy to oblige
Pause does 2 things, waits for a keypress and displays Press any key to continue ....
Redirecting the output of Pause means it will still wait for a keypress, but the message will not appear, it is usually accompanied by a customised message using Echo
...... Echo Processing complete, press a key to exit Pause>Nul
Thank you Graham.
And to think all these decades I've been ecstatic with the simple return of the command prompt.
|