How to run commands in command line from a script

Peter Hansen peter at engcorp.com
Fri Jul 1 00:08:44 EDT 2005


Peter Hansen wrote:
> Ivan Shevanski wrote:
>> Alright well I'm quite a noob and when I run a simple command to 
>> change the current directory, nothing happens.  I made a little test 
>> script to show it:
> 
> Generally, the only way to use an application (i.e. a program like the 
> Python interpreter, or your own .exe) to change the working folder is to 
> have your script executed from within a batch file, write out a new 
> batch file in your script, and then have the calling batch file execute 
> that script if it exists. 

And, after that long-winded reply, here's another option, if you're just 
trying to change the directory _within_ your app but don't care if the 
change persists:

import os
os.chdir(r'c:\Program Files')

-Peter



More information about the Python-list mailing list