Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Using a .bat file to run another .bat file - 2nd .bat file (fails)

03 Sep 2013   #11
MilesAhead

Windows 7 32 bit
 
 

Hmmm, instead of using Call to call another batch, how about putting all the batch lines after a label making one big batch file? Then you test if you want to do the action or exit. If not the action jump to a line label at the end of the batch. If you want to do the action, jump to a line label at the start of the lines from the 2nd batch file. See batch docs for "goto" command instead of call.


My System SpecsSystem Spec
.
03 Sep 2013   #12
jfk92

Various - W7 32bit, 64bit
 
 

this was a great idea. unfortunately I seem to get the same results regardless of how I am firing this - it seems that with the 'prompt' (first batch) even IF bundled into a single file the "PAUSE" action or something some how causes the second batch (even if embedded in the same bat file) to ignore the execution activities of backing up.....the concept is so simple - msft makes things so complicated!!!
My System SpecsSystem Spec
04 Sep 2013   #13
UsernameIssues

W7 Pro SP1 64bit
 
 

I've followed this thread since the first day that you posted it. I've tried/failed several times to replicate your issue. My 2nd batch file runs just fine no matter if the first file has lost focus or not.

Conditions gleaned from the original post:
1st batch file starts via a scheduled task
1st batch file is left at the pause line while other tasks are performed
(thus the 1st batch file is not in focus for a while)
1st batch file is brought back into focus and "any key" is pressed

I added a ping delay so that I could take the first batch file out of focus again before it called the 2nd batch file... but I got the same results without the ping delay. The 2nd batch file worked every time.



without the ping delay


Click on each image to enlarge:
Using a .bat file to run another .bat file - 2nd .bat file (fails)-st1.png

Using a .bat file to run another .bat file - 2nd .bat file (fails)-st2.png

Using a .bat file to run another .bat file - 2nd .bat file (fails)-st3.png

Using a .bat file to run another .bat file - 2nd .bat file (fails)-st4.png

Using a .bat file to run another .bat file - 2nd .bat file (fails)-st5.png

Instead of us attempting to replicate your failure, please see if you can replicate my success using the simple/tiny batch files shown above (along with the simple scheduled task). Then little by little, add complexity to the 2nd batch file and let's see where it starts to fail.


My System SpecsSystem Spec
.

04 Sep 2013   #14
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by jfk92 View Post
this was a great idea. unfortunately I seem to get the same results regardless of how I am firing this - it seems that with the 'prompt' (first batch) even IF bundled into a single file the "PAUSE" action or something some how causes the second batch (even if embedded in the same bat file) to ignore the execution activities of backing up.....the concept is so simple - msft makes things so complicated!!!
Hmm, it may be easier to learn a basic like scripting language, such as AutoIt, than to circumvent a weird quirk in the shell. If nothing else, coming up with another implementation may give more understanding. Often the first program I write to do something allows me to see how the design sucked. Then I rewrite it using the knowledge gained via trial and error.
My System SpecsSystem Spec
04 Sep 2013   #15
jfk92

Various - W7 32bit, 64bit
 
 

thanks UsernameIssues and MilesAhead.

UsernameIssues - I took your advice and tried to replicate what you have. I changed my backup script to the exact same simple temp file directory, single file named "hi.txt" and a copy to a server directory. Bat file 1 opening, pausing, losing focus, getting focus with an 'any key' press and firing the simple copy command from bat file #2 - same results - if I 'lose focus' the second file runs and 'blinks' like it's run but no file is copied. IF I fire the 1st file again (either manually OR using the trigger timer) and in the first DOS screen as it's active, without 'losing focus' hit any key - the file is copied. I cannot replicate your success - my task schedule settings are identical to yours - except for I have it running with highest privileges, starting only if a specific network connection is available, and wake computer to run task. but these don't explain why losing focus will affect the execution of the second file.

thank you for the time and thought you have put in with the video and pictures - most helpful. I don't want you to waste any more of your own time worrying about this - I may have to "*gasp*" put it in the hands of the users where they actually intentionally click to back up periodically - and have to remember to. until I can put new sofware on our server that will extract the info nightly for them.... so much for being clever with bat files!

thank you all for your input - of course I'm interested in hearing more suggestions if anyone is interested/challenged - but I've clearly exhausted everything I can think of at this time with my limited abilities. thank you again.
My System SpecsSystem Spec
04 Sep 2013   #16
UsernameIssues

W7 Pro SP1 64bit
 
 

How weird that it fails for you.

You might try copying the file to another spot on the local hard drive,
edit: to clarify - I'm suggesting to have the batch file copy a test file from one place on the local drive to another place on the local drive.

When I first saw this thread, I was ready to post a suggestion that you move towards using Cobian Backup. I use it to backup compress and backup Outlook PST files while they are still in use. That Cobian tool also removes old backups... I keep 90 days worth for most users.

But - I'm unsure what the for sale sign means on Cobian's tool. I hope that it will remain free for business use.
My System SpecsSystem Spec
10 Sep 2013   #17
maxseven

Windows 7 Home Premium 64bit 6.1 Build 7601 (SP1)
 
 

Quote   Quote: Originally Posted by jfk92 View Post
I may have to "*gasp*" put it in the hands of the users where they actually intentionally click to back up periodically - and have to remember to.
Why don't you at least leave the Scheduled Task in place to pop-up and remind them to do a backup--make it fun by saying "Close all programs, click Backup on your desktop, and go for a coffee/soda!" or something.

That will at least get you part-way there (and give you an "out" when someone inevitably ignores the warnings and one day loses valuable data).

I think a reminder is valuable--whenever I ask someone about when they last made a backup they say "uh, I think it was just last week" and of course it turns-out it was last MONTH or even worse!

My System SpecsSystem Spec
Reply

 Using a .bat file to run another .bat file - 2nd .bat file (fails)




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
when open a word file or pwrpnt file another file is opens
God bless you, I am not a computer person please help me to fix the problem I have. Every time I open a word, power point and note pad program another file is opens with that (with a infinity sign in the front with the same extension ) is that a thread or how can I stop this thank you...
Microsoft Office
CBS.log file: Getting a usable txt file and interpreting the file
First, what does "CBS" mean in cbs.log? Does the cbs.log file show only errors? I create a cbs.log file a lot, so if there are errors, I'd like to correct them. However, my computer seems to be working just fine. sfc /scannow shows everything is OK. I've tried findstr /c:""...
Performance & Maintenance
5.4 GB file fails to download
Hello! I'm trying to download 5.4 GB file from Google Drive and it fails at some point after 2/3. I tried to use several browsers but still the download fails with an error: "the file could not be saved, because the source file could not be read." Please help, i need it for my work badly! ...
Network & Sharing
hidden file of docx file created with ~$name of file.docx file
whenever I open docx file there is hidden file ~$name of file.docx created. which type of file is that? Is it in virus, maleware. for example If I open house.docx file then ~$house.docx file created which is hidden form. I had saw this file when i select show all hidden file option. when i try to...
Microsoft Office
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
How do I change a file's file type (not only file association)?
I need to change a zip file to an epub file. I have heard this can be done, but when I add the .epub after the file name, I notice the file is still actually zip type file when I right click properties. This is causing a problem when I try to open it in in different ebook reader programs. I...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 17:51.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App