Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Cannot execute Windows commands via Python in 64-bit
- From: nsjmetzger at gmail.com (minitotoro)
- Subject: Cannot execute Windows commands via Python in 64-bit
- Date: 4 May 2007 12:24:38 -0700
On May 2, 4:15 pm, minitotoro <nsjmetz... at gmail.com> wrote: > On May 2, 3:46 pm, Larry Bates <larry.ba... at websafe.com> wrote: > > > > > minitotoro wrote: > > > On May 2, 3:07 pm, Larry Bates <larry.ba... at websafe.com> wrote: > > >> nsjmetz... at gmail.com wrote: > > >>> I have a script that runs fine in Windows 2003 (32-bit). It basically > > >>> calls the Windows defrag command. When I try the exact same code on > > >>> Windows 2003 (64-bit) I get the following message: > > >>> C:\Scripts>autodefrag.py > > >>> Starting defragment: defrag -v C: >>c:/Scripts/DEFRAG20070502.log > > >>> 'defrag' is not recognized as an internal or external command, > > >>> operable program or batch file. > > >>> I have tried defrag.exe and even giving it the full path to > > >>> defrag.exe. Always the same result. Here is the python code that is > > >>> generating this error: > > >>> cmd = "defrag -v C: >>c:/Scripts/DEFRAG20070502.log" > > >>> print "Starting defragment: ", cmd > > >>> errorlevel = os.system(cmd) > > >>> Anyone know what the heck is going on and how to fix it? This code > > >>> works fine on my 32-bit windows machines. > > >>> Thanks. > > >> Sounds like system can't find defrag. Usually this is because of a path > > >> issue. Are you running the script in the foreground or scheduled? Can > > >> you open a command prompt and enter the command and have it work? If > > >> you give full path, this shouldn't be the problem. > > > >> -Larry > > > > I have tried foreground and scheduled (neither works). I can run > > > defrag from the command prompt with no problem. If I give it the full > > > path in the script it still fails. I am completely befuddled. Help. > > > Copy and paste the traceback here for us. > > > -Larry > > I'm sorry, but I'm not familiar with traceback. How do I use it? > Thanks. Upon further investigation it turned out to be a windohs 64-bit issue (which is what I was afraid of). I did however find an asinine work around. Make a copy of defrag.exe from the system32 folder and paste it in the same directory as the python script. Voila! It now works. Piece of junk windohs... :-S
- Follow-Ups:
- Cannot execute Windows commands via Python in 64-bit
- From: Tim Roberts
- Cannot execute Windows commands via Python in 64-bit
- References:
- Cannot execute Windows commands via Python in 64-bit
- From: nsjmetzger at gmail.com
- Cannot execute Windows commands via Python in 64-bit
- From: Larry Bates
- Cannot execute Windows commands via Python in 64-bit
- From: minitotoro
- Cannot execute Windows commands via Python in 64-bit
- From: Larry Bates
- Cannot execute Windows commands via Python in 64-bit
- From: minitotoro
- Cannot execute Windows commands via Python in 64-bit
- Prev by Date: My Python annoyances
- Next by Date: Where are the strings in gc.get_objects?
- Previous by thread: Cannot execute Windows commands via Python in 64-bit
- Next by thread: Cannot execute Windows commands via Python in 64-bit
- Index(es):