Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8270 > unrolled thread

Python 2.7 and cmd on Windows 7 64 (files lost)

Started by"Michel Claveau - MVP"<enleverLesX_XXmcX@XmclavXeauX.com.invalid>
First post2011-06-23 08:33 +0200
Last post2011-06-23 09:14 +0100
Articles 7 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Python 2.7 and cmd on Windows 7 64  (files lost) "Michel Claveau - MVP"<enleverLesX_XXmcX@XmclavXeauX.com.invalid> - 2011-06-23 08:33 +0200
    Re: Python 2.7 and cmd on Windows 7 64  (files lost) Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-06-23 09:31 +0200
      Re: Python 2.7 and cmd on Windows 7 64  (files lost) "Michel Claveau - MVP"<enleverLesX_XXmcX@XmclavXeauX.com.invalid> - 2011-06-23 11:10 +0200
        Re: Python 2.7 and cmd on Windows 7 64  (files lost) "Martin v. Loewis" <martin@v.loewis.de> - 2011-06-24 09:34 +0200
    Re: Python 2.7 and cmd on Windows 7 64  (files lost) Tim Golden <mail@timgolden.me.uk> - 2011-06-23 08:31 +0100
      Re: Python 2.7 and cmd on Windows 7 64  (files lost) Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-06-23 10:08 +0200
        Re: Python 2.7 and cmd on Windows 7 64  (files lost) Tim Golden <mail@timgolden.me.uk> - 2011-06-23 09:14 +0100

#8270 — Python 2.7 and cmd on Windows 7 64 (files lost)

From"Michel Claveau - MVP"<enleverLesX_XXmcX@XmclavXeauX.com.invalid>
Date2011-06-23 08:33 +0200
SubjectPython 2.7 and cmd on Windows 7 64 (files lost)
Message-ID<4e02de32$0$30749$ba4acef3@reader.news.orange.fr>
Hi!

(sorry for my bad english...)

On Win 7 64 bits:
  Command-Line
  CD \Python27
  dir C:\Windows\System32\SoundRecorder.exe    :==> OK
  Python.exe

>>> import os
>>> os.system("dir C:\\Windows\\System32\\SoundRecorder.exe")  

==> Do not found the file !!!

and os.system("cmd /k")  then  "dir C:\Windows\System32\SoundRecorder.exe"  do not found
anyway.

But:
  {Ctrl-Z} in Python
  then  dir C:\Windows\System32\SoundRecorder.exe  run OK

Therefore, is the problem only in Python? 


@+
-- 
Michel Claveau 

  

[toc] | [next] | [standalone]


#8278

FromThorsten Kampe <thorsten@thorstenkampe.de>
Date2011-06-23 09:31 +0200
Message-ID<MPG.286d0a327002d85198981e@news.individual.de>
In reply to#8270
* Michel Claveau - MVP (Thu, 23 Jun 2011 08:33:20 +0200)
> On Win 7 64 bits:
>   Command-Line
>   CD \Python27
>   dir C:\Windows\System32\SoundRecorder.exe    :==> OK
>   Python.exe
> 
> >>> import os
> >>> os.system("dir C:\\Windows\\System32\\SoundRecorder.exe")  
> 
> ==> Do not found the file !!!
> 
> and os.system("cmd /k")  then  "dir C:\Windows\System32\SoundRecorder.exe"  do not found
> anyway.

This is because 32-bit processes (Python, 32-bit cmd) cannot see the 64-
bit DLLs in System32.
 
> But:
>   {Ctrl-Z} in Python
>   then  dir C:\Windows\System32\SoundRecorder.exe  run OK

Now you are running 64-bit Cmd.
 
> Therefore, is the problem only in Python? 

Of course not (see above).

Thorsten

[toc] | [prev] | [next] | [standalone]


#8285

From"Michel Claveau - MVP"<enleverLesX_XXmcX@XmclavXeauX.com.invalid>
Date2011-06-23 11:10 +0200
Message-ID<4e0302f5$0$30791$ba4acef3@reader.news.orange.fr>
In reply to#8278
Re !

> This is because 32-bit processes (Python, 32-bit cmd) cannot see the 
> 64-bit DLLs in System32.

Thanks. 
You are right... but it is not enought.

This command:  echo %PROCESSOR_ARCHITECTURE%
give the statut:
   32:  x86
   64:  AMD64

and  DIR C:\Windows\System32\SoundRecorder.exe  is OK in 64, not in 32.



But if, in 64 mode, I copy SoundRecorder.exe to sr.exe, then I rename
sr.exe to sr.txt, the file (which is not an executable) is not visible 
in 32 mode.
And, if I move (or copy) sr.txt in an USB-drive, the file become visible 
in 32 mode !!!???

Therefore, Windows has a "trick" for mark the file like visible, or not,
in 32 mode. What trick?


OK, it is not a Python problem. 
Then... thanks again for your explanations.


@-salutations
-- 
Michel Claveau 







[toc] | [prev] | [next] | [standalone]


#8356

From"Martin v. Loewis" <martin@v.loewis.de>
Date2011-06-24 09:34 +0200
Message-ID<4E043DEF.1050502@v.loewis.de>
In reply to#8285
> Therefore, Windows has a "trick" for mark the file like visible, or not,
> in 32 mode. What trick?

It's called file system redirection. When you access \windows\system32
in a 32-bit process, you *actually* access \windows\syswow64, which
has entirely different files.

The same also happens for parts of the registry.

Regards,
Martin

[toc] | [prev] | [next] | [standalone]


#8279

FromTim Golden <mail@timgolden.me.uk>
Date2011-06-23 08:31 +0100
Message-ID<mailman.317.1308814289.1164.python-list@python.org>
In reply to#8270
On 23/06/2011 07:33, Michel Claveau - MVP wrote:
> Hi!
>
> (sorry for my bad english...)
>
> On Win 7 64 bits:
>    Command-Line
>    CD \Python27
>    dir C:\Windows\System32\SoundRecorder.exe    :==>  OK
>    Python.exe
>
>>>> import os
>>>> os.system("dir C:\\Windows\\System32\\SoundRecorder.exe")
>
> ==>  Do not found the file !!!
>
> and os.system("cmd /k")  then  "dir C:\Windows\System32\SoundRecorder.exe"  do not found
> anyway.
>
> But:
>    {Ctrl-Z} in Python
>    then  dir C:\Windows\System32\SoundRecorder.exe  run OK
>
> Therefore, is the problem only in Python?

Certain commands, including "dir" and "copy" are not executables
in their own right, but merely subcommands of cmd.exe. You've
got two options in Python:

   os.system (r"cmd /c dir c:\windows")

or:

   subprocess.call (["dir", "c:\\windows"], shell=True)

which basically does it for you behind the scenes.

I hope that helps..

TJG

[toc] | [prev] | [next] | [standalone]


#8281

FromThorsten Kampe <thorsten@thorstenkampe.de>
Date2011-06-23 10:08 +0200
Message-ID<MPG.286d12f682a331b98981f@news.individual.de>
In reply to#8279
* Tim Golden (Thu, 23 Jun 2011 08:31:26 +0100)
> 
> Certain commands, including "dir" and "copy" are not executables
> in their own right, but merely subcommands of cmd.exe.

Right, "internal commands".

> You've got two options in Python:
> 
>    os.system (r"cmd /c dir c:\windows")

os.system automatically runs a shell (cmd) - see the documentation.
 
Thorsten

[toc] | [prev] | [next] | [standalone]


#8282

FromTim Golden <mail@timgolden.me.uk>
Date2011-06-23 09:14 +0100
Message-ID<mailman.319.1308816895.1164.python-list@python.org>
In reply to#8281
On 23/06/2011 09:08, Thorsten Kampe wrote:
> * Tim Golden (Thu, 23 Jun 2011 08:31:26 +0100)
>>
>> Certain commands, including "dir" and "copy" are not executables
>> in their own right, but merely subcommands of cmd.exe.
>
> Right, "internal commands".
>
>> You've got two options in Python:
>>
>>     os.system (r"cmd /c dir c:\windows")
>
> os.system automatically runs a shell (cmd) - see the documentation.

Thanks: should have checked my sources before writing :(

TJG

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web