There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware network networking outlook outlook 2003 outlook express partition password printer problem ram router security slow software sound trojan usb video virus vista windows windows xp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
bach programming - running external bach files


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
marksu's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
Experience: Intermediate
11-Oct-2007, 01:52 PM #1
bach programming - running external bach files
I have 10 ready made bach files.
For example bachfile1.bat ,bachfile2.bat, bachfile3.bat ... etc

I would need a separate batch file that when it is run it runs batchfile1.bat.
Next time main batch file is run again, it would run batchfile2.bat etc.
When run 10 times, it would start again back from batchfile1.bat.

One problem is that the main bach file is allways run sameway so number paramethers can be sent to main bach file.

I do have programming experience but not mutch in batch programming.

Does any one have the knowledge how sutch batch file should be created?

marksu
marksu's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
Experience: Intermediate
11-Oct-2007, 05:49 PM #2
Never mind I found out it my self.
This runst bachfile1 to bachfile11 then next run number 12 it runs from start bachfile1 rtc...


@echo off

:: Works by comparing each digit

if [%E0%]==[] set E0=0

if %E0%==11 set E0=0
if %E0%==10 set E0=11
if %E0%==9 set E0=10
if %E0%==8 set E0=9
if %E0%==7 set E0=8
if %E0%==6 set E0=7
if %E0%==5 set E0=6
if %E0%==4 set E0=5
if %E0%==3 set E0=4
if %E0%==2 set E0=3
if %E0%==1 set E0=2
if %E0%==0 set E0=1


bachfile%E0%
marksu's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
Experience: Intermediate
12-Oct-2007, 05:51 AM #3
Hmm still some problems.
It works fine if using same memory space.
Meaning that keeping the dos prompt open and running the script time after time.

The problem is that my app that runs the script allways starts a new memoryspace so i loose the counter number as it is averytime reset to 0.

How can I save the number?

One possibility is to save the number to a file.
For example (I think?)
If exist counterValue.txt counterValue.txt
echo %E0% >> counterValue.txt

but how do i use that value in my external batch file.
meaning how do i read the number?
JohnWill's Avatar
Computer Specs
Moderator with 78,896 posts.
 
Join Date: Oct 2002
Location: South Eastern PA, USA
Experience: Advanced age & experience
12-Oct-2007, 09:17 AM #4
Why not write a 10 line program to do the same thing? Personally, I'd probably use something like AutoIt to do this task, makes it simple.
marksu's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
Experience: Intermediate
12-Oct-2007, 01:03 PM #5
Quote:
Originally Posted by JohnWill
Why not write a 10 line program to do the same thing? Personally, I'd probably use something like AutoIt to do this task, makes it simple.
I dloaded iniread and inimod from Internet that i found through google..
This should work but dont .
Some reason i cant get the value to E0 even though iniread looks like reading the inifile.

@echo off

:: reading ini file to get the counter value
iniread "counter.ini" "counter" "E0" "E0"

:: Works by comparing each digit

if %E0%==18 set E0=0
if %E0%==17 set E0=18
if %E0%==16 set E0=17
if %E0%==15 set E0=16
if %E0%==14 set E0=15
if %E0%==13 set E0=14
if %E0%==12 set E0=13
if %E0%==11 set E0=12
if %E0%==10 set E0=11
if %E0%==9 set E0=10
if %E0%==8 set E0=9
if %E0%==7 set E0=8
if %E0%==6 set E0=7
if %E0%==5 set E0=6
if %E0%==4 set E0=5
if %E0%==3 set E0=4
if %E0%==2 set E0=3
if %E0%==1 set E0=2
if %E0%==0 set E0=1

// this runs the external bach file
runBatch%E0%

:: write the new value to ini file
inimod counter.ini "counter" "E0" %E0%

Well maybe I have to take a look at Autoit. I just prefer not to start learn new script languges.
marksu's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
Experience: Intermediate
13-Oct-2007, 11:12 AM #6
Well the iniread.exe file dont seem to work on my XP OS so I replaced that line with:

:: get E0 value from ini file
setlocal enableextensions
for /f "tokens=2 delims==" %%? in (
'find /i "E0" ^< counter.ini') do set E0=%%?
if "%E0:~0,1%" equ " " set E0=%E0:~1%
echo E0= %E0%


Now it seems to work.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:18 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.