Home / Microsoft / Microsoft DOS / Calling a batch file from another batch file
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2  All - (Bottom) Print
Author Topic: Calling a batch file from another batch file  (Read 24374 times)
ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« on: January 29, 2009, 12:39:06 PM »

I am having problem calling a batch file inside another batch file. I have tested each of them individually and all of them works. Can someone check my codes please. Thanks.

Main batch
==========
@echo off
("C:\Program Files\SI_SCOPE\si_scope32" < si_scope32 /p1:fdf0h /p2:fdf8h /i1:07 /i2:07 /BOARD_TYPE:5 /NOALERT /B:128)
at 1:15PM /call "C:\Program Files\SI_SCOPE\close.bat"
at 1:16PM /call "C:\Program Files\SI_SCOPE\copy.bat"
at 1:17PM /call "C:\Program Files\SI_SCOPE\Hard Fault Captures\RenameFileToDate.bat"
at 1:20PM /call "C:\WINDOWS\reboot.bat"
==========


Close
==========
@echo off
taskkill /im "si_scope32.exe" /f
==========


Copy
==========
@echo off
copy  "C:\Program Files\SI_SCOPE\SI_SCOPE.DAT" "C:\Program Files\SI_SCOPE\Hard Fault Captures"
==========


RenameFileToDate
==========
@echo off
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "SI_SCOPE.DAT" %%e-%%f-%%g.dat
==========

Reboot
==========
@echo off
shutdown -r
==========
IP logged
fireballs
Apprentice



Thanked: 3
Posts: 562

Code:Terminal

« Reply #1 on: January 30, 2009, 03:41:54 AM »

at 1:15PM /call "C:\Program Files\SI_SCOPE\close.bat"
at 1:16PM /call "C:\Program Files\SI_SCOPE\copy.bat"
at 1:17PM /call "C:\Program Files\SI_SCOPE\Hard Fault Captures\RenameFileToDate.bat"
at 1:20PM /call "C:\WINDOWS\reboot.bat"

Is this literally what you've got? Unless you've got a third party app that understands this a standard DOS installation won't know what you're on about.

You're best bet i reckon is to use
Code: [Select]
start /wait That way it will run whatever you want to run first then the second thing after the first has finished.

FB
IP logged

Next time google it.
devcom
Apprentice



Thanked: 37
Posts: 521


« Reply #2 on: January 30, 2009, 05:54:58 AM »

@fireballs
http://www.ss64.com/nt/at.html

@ABIAMDTECH
have you tried using just call, without '/' ?
IP logged

Download: Choice.exe
fireballs
Apprentice



Thanked: 3
Posts: 562

Code:Terminal

« Reply #3 on: January 30, 2009, 06:12:00 AM »

I did wonder. Thanks Devcom.

FB
IP logged

Next time google it.
ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« Reply #4 on: February 02, 2009, 08:35:50 AM »

Hi guys, I have tried both method "start/wait" and removeing the / from call. Both method does not work. I check in the schedule task folder and it shown "could not start" in the status tab. Do you have any other methods to run these bat files?
IP logged
devcom
Apprentice



Thanked: 37
Posts: 521


« Reply #5 on: February 02, 2009, 12:59:24 PM »

you can try this
Code: [Select]
@echo off
:LOOP
set cTime=%time:~0,-3%

if '%cTime%' equ '13:15' call "C:\Program Files\SI_SCOPE\close.bat"
if '%cTime%' equ '13:16' call "C:\Program Files\SI_SCOPE\copy.bat"
if '%cTime%' equ '13:17' call "C:\Program Files\SI_SCOPE\Hard Fault Captures\RenameFileToDate.bat"
if '%cTime%' equ '13:20' call "C:\WINDOWS\reboot.bat"

goto LOOP

but this code must run all time in background
IP logged

Download: Choice.exe
ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« Reply #6 on: February 02, 2009, 01:47:23 PM »

devcom, I am not sure what is the problem, but your code does not work too. When I tried setting up schedule task, it said that there is some problem in the "account" and my not start the task correctly. By "account" does it mean the directory?
IP logged
devcom
Apprentice



Thanked: 37
Posts: 521


« Reply #7 on: February 02, 2009, 02:14:51 PM »

maybe you are not logged as admin ?
and what is not working in my code ?
IP logged

Download: Choice.exe
Geek-9pm
Sage



Thanked: 373
Posts: 8,930

Computer: Specs
Experience: Expert
OS: Windows XP


Geek After Dark

Geek 9pm blog
« Reply #8 on: February 02, 2009, 04:17:13 PM »

Inwhat directory and/or drive do you start?
When you call a batch deep in the tree, it does not know that you want it to work in that directory, the work is done in the directory where you started. Is that what you want?
IP logged

ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« Reply #9 on: February 02, 2009, 05:50:22 PM »

@devcom, yes, I logged in as admin. I am not sure what is not working in the code, but I do know that it is not running those batch files. I will make the batch file part of "start up" instead of schedule task tomorrow and see if it does it differently. Thanks

@Greek-9pm, SI_SCOPE is the directory/application I want to run my batch files. 
IP logged
Geek-9pm
Sage



Thanked: 373
Posts: 8,930

Computer: Specs
Experience: Expert
OS: Windows XP


Geek After Dark

Geek 9pm blog
« Reply #10 on: February 02, 2009, 06:33:37 PM »

If you want the batch files to open in thier directory then you would do this at the start of the job.
Code: [Select]
C:
CD \Program Files\SI_SCOPE\
That way all input and output or what ever is in that directory. And you would not have to use the full path name for the batch files.
IP logged

ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« Reply #11 on: February 02, 2009, 07:40:23 PM »

Thanks Geek-9pm, I will try that out tomorrow.
IP logged
ABIAMDTECH
Topic Starter
Rookie



Posts: 17


« Reply #12 on: February 03, 2009, 09:13:29 AM »

Hi guys, I have tried the two codes together. It runs a continuous loop. But that is all. When it reaches the set time, nothing happen. It does not execute any of the batch file.
==========================
C:
CD \Program Files\SI_SCOPE\
:LOOP
set cTime=%time:~0,-3%

if '%cTime%' equ '10:06' call Copy.bat
if '%cTime%' equ '10:07' call \Hard Fault Captures\RenameFileToDate.bat
if '%cTime%' equ '10:08' call C:\WINDOWS\reboot.bat

goto LOOP
==========================
IP logged
TheShredder
Greenhorn



Posts: 5


« Reply #13 on: February 03, 2009, 12:56:27 PM »

if '%cTime%' equ '10:06' call Copy.bat
if '%cTime%' equ '10:07' call \Hard Fault Captures\RenameFileToDate.bat
if '%cTime%' equ '10:08' call C:\WINDOWS\reboot.bat
==========================

equ?   ??? i've not yet tried to do anything with time in my programs, but i've used the IF statement quite a bit and i've always used == there. perhaps trying it like

if %cTime% == "10:06" call Copy.bat
if %cTime% == "10:07" call \Hard Fault Captures\RenameFileToDate.bat
if %cTime% == "10:08" call C:\WINDOWS\reboot.bat
IP logged

no, i don't shred, but my shredder can overwrite any number of files 9 times (more then the russian goverment) before deletion. oh, and it does it in 4 seconds. (tested up to 11,000 files at once.)
-pm me for details or if you' like a free download)
devcom
Apprentice



Thanked: 37
Posts: 521


« Reply #14 on: February 04, 2009, 12:51:13 PM »

Code: [Select]
CD \Program Files\SI_SCOPE\
set cTime=%time:~0,-3%

if '%cTime%' equ '10:06' call Copy.bat
if '%cTime%' equ '10:07' call \Hard Fault Captures\RenameFileToDate.bat
if '%cTime%' equ '10:08' call C:\WINDOWS\reboot.bat

pause
try this code and copy here all text that apear in console box
IP logged

Download: Choice.exe
Pages: [1] 2  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Calling a batch file from another batch file « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.124 seconds with 21 queries.