473,322 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Run batch files in Windows XP

Hi,

I'm a newbie and I was wondering if anyone knew a (Python) script to
run 4 batch files, one after the other (assuming the directories are
known). It would be better if all 4 batch files could run
simultaneously, but that might break Windows... ;) The problem I had
was I couldn't get the files to RUN, only to OPEN. Thanks for the
help!!!

pseudo-code looks like this
Get directory Run batch1
Run batch2
Run batch3
Run batch4


Jul 25 '05 #1
7 9033
er*******@gmail.com wrote:
I'm a newbie and I was wondering if anyone knew a (Python) script to
run 4 batch files, one after the other (assuming the directories are
known). It would be better if all 4 batch files could run
simultaneously, but that might break Windows... ;) The problem I had
was I couldn't get the files to RUN, only to OPEN. Thanks for the
help!!!


You shouldn't need a Python program for that.

To run the not simultaneously:

call batch1.bat
call batch2.bat
call batch3.bat
call batch4.bat

Put those commands with appropriate names in a fifth batch file and
execute that and it will work.

To run them simultaneously (which won't break Windows, but might not do
what you would like, depending on what those batch files actually do),
just add the "start" command into the equation. You can get help on the
start command using "start /?" at a DOS prompt.

-Peter
Jul 25 '05 #2
Thanks Peter.
The issue is I haven't done very much batch programming. I need to
prompt the user for input and each batch file is in a different
directory. How do I change directories and prompt for user input?
Thanks!

Jul 25 '05 #3
Ernesto wrote:
The issue is I haven't done very much batch programming. I need to
prompt the user for input and each batch file is in a different
directory. How do I change directories and prompt for user input?


Ah, now you're talking things where Python, while not strictly required,
can start to make things easier. :-)

To run external things like batch files, you import the "os" module and
use the system() function:

import os
os.system('somebatchfile.bat')

Since you're prompting the user for input first, presumably the input is
passed to the batch file in some way, like so:

input = raw_input('Enter your incredibly useful info now:')

("raw_input" is a builtin... good to learn about as many of those as you
can handle by reading the docs here:
http://docs.python.org/lib/built-in-funcs.html . Some of those are
absolutely not important to you at this early stage, others are.)

Then with the input you've collected, you could pass it to the batch
file like so:

os.system('myfile.bat %s' % input)

The %s and % together result in whatever text the user entered being
added on the command line for the call to myfile.bat, exactly as though
it had been executed manually with the same input.

-Peter
Jul 25 '05 #4
Thanks.

Yeah I started to write in Python. Looks like this:

************************************************** ****
import os
from os.path import join

# Get input from user and make sure it is valid

fileDirec = raw_input("\nEnter the path of where your
STMP3XXX_SDK_FIRMWARE\nis located (i.e. C:\) : ")
if not os.path.exists(fileDirec):
exit(" ** File or path does not exist... exiting ** ")
# Builds all binaries simultaneously for SDK 3.050
def buildBinaries(_path):
_bootmanagerPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\DeviceDriver\Media\SmartMed ia\BootManager\STMP3500\make")
_usbmscPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\usb msc\make")
_playerPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\pla yer\make")
_mtpPath = join(_path,
"STMP3XXX_SDK_FIRMWARE\Projects\Sdk\lcdexample\mtp \make")

# First build bootmanager...change to that directory
# and run the bootmanager file... Similarly for the others...
os.chdir(_bootmanagerPath)
os.execl(("bootmanager.bat"),("BOOTMANAGER ALL"))

os.chdir(_usbmscPath)
os.execl(("usbmsc.bat"),("USBMSC ALL UPDATER"))

os.chdir(_playerPath)
os.execl(("player.bat"),("PLAYER ALL"))

os.chdir(_mtpPath)
os.execl(("mtp.bat"),("MTP ALL"))

# After gathering user input, call routine to build binaries...
buildBinaries(fileDirec)
************************************************** ****************

The issue is after the first execution of os.execl, the script stops
altogether. In other words after bootmanager.bat executes, its over.
I would love to Python if I could get all scripts to execute (executing
simultaneously would be a major + !)
I'll try os.system
THANKS!!!

Jul 25 '05 #5
Looks like I'm not getting my parameters to my batch file correctly.
I'm using os.system like this:
os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")

where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
That must not be right?

Jul 25 '05 #6
Ernesto wrote:
Looks like I'm not getting my parameters to my batch file correctly.
I'm using os.system like this:
os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")

where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
That must not be right?


The batch file will see two parameters (in %1 and %2) if that's not what
you want, put double quotes around the %s, like so:

os.system('bootmanager.bat "%s"' % "BOOTMANAGER ALL")
--
Benji York

Jul 25 '05 #7
On 25 Jul 2005 12:57:23 -0700, "Ernesto" <er*******@gmail.com> declaimed
the following in comp.lang.python:
Looks like I'm not getting my parameters to my batch file correctly.
I'm using os.system like this:
os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")

where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
That must not be right?
Is there a possibility you have too much specified there...

What do you really type at a command prompt? The above code is
the equivalent of

C:\>bootmanager.bat BOOTMANAGER ALL

where C:\ is the prompt string.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 26 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Jorgensen | last post by:
I remember that I used to set up utility batch files, and create Windows shortcuts to them that would ask the user for parameters to supply to the batch files. From what I can tell, this...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
4
by: | last post by:
Hello, I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am...
0
by: ee_stevek | last post by:
hi guys, here is my problem: i have to maintain a web vb.net application developped some times ago. The application was developped on Windows2000 SP3 with Visual Studio 2003 (7.1). and the...
4
by: MLH | last post by:
SHELLing to run a batch file in a cmd window does not work with all batch files. Here are two examples... c:\windows\Doc_Dirs.bat ==DIR *. /s WinDirs.txt - and - c:\db\timnall\getconf.bat...
3
by: John | last post by:
Hi. I have a number of batch jobs that are ran nightly on our Windows 2000 based Oracle 8.1.7 (soon to be 9i) server. I have these designed just right, so the Windows Scheduled Tasks runs them...
4
watertraveller
by: watertraveller | last post by:
Hi. I'm new to batch files, and relatively new to the Windows command line in general. I'm making a batch file for the Windows XP command line. I want to examine, for each line of a text file,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.