简体   繁体   English

从32位python调用64位控制台

[英]Invoking 64-bit console from 32-bit python

I'm attempting to write a script that will gather the output of a few basic windows commands into a set of files, and am finding my vssadmin commands frustrating. 我试图编写一个脚本,将一些基本Windows命令的输出收集到一组文件中,并且发现我的vssadmin命令令人沮丧。 The command is a relatively simple 该命令比较简单

os.system('vssadmin list writers>> x:\foo\vss.txt')

The problem is that I'm writing in python 32-bit and want to make sure this will function on 64-bit Windows. 问题是我正在用32位python编写代码,并希望确保它可以在64位Windows上运行。 When executing this, the return is: 执行此操作时,返回为:

vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool (C) Copyright 2001-2005 Microsoft Corp. vssadmin 1.1-卷影复制服务管理命令行工具(C)版权所有2001-2005 Microsoft Corp.。

Error: A Volume Shadow Copy Service component encountered an unexpected error. 错误:卷影复制服务组件遇到意外错误。 Check the Application event log for more information. 检查应用程序事件日志以获取更多信息。

Can I invoke a 64-bit command line from 32-bit python and decide whether to invoke it with a bit-depth detecting function, or is there another more elegant solution? 我可以从32位python调用64位命令行并决定是否使用位深度检测功能来调用它,还是有另一个更优雅的解决方案?

Follow-up : using MBu as a jumping off point I found that the following command does the trick: 后续 :使用MBu作为起点,我发现以下命令可以解决问题:

os.system('%systemroot%\\sysnative\\cmd.exe /c vssadmin list writers > x:\\foo\\vss.txt')

明确启动C:\\Windows\\SysWOW64\\vssadmin.exe以始终获取64位版本。

Under Windows 2008 or newer you can launch c:\\Windows\\Sysnative\\vssadmin.exe . 在Windows 2008或更高版本下,您可以启动c:\\Windows\\Sysnative\\vssadmin.exe Under Windows 2003 a hotfix is needed, but you can also create a filesystem junction to reach the 64-bit system file from 32-bit applications. 在Windows 2003下,需要一个修补程序,但您也可以创建一个文件系统联结,以从32位应用程序访问64位系统文件。 For details see my answer to this question . 有关详细信息,请参阅我对这个问题的回答 While it was about launching 64-bit cmd.exe from 32-bit cmd.exe, the rules stay the same for all applications. 从32位cmd.exe启动64位cmd.exe时,所有应用程序的规则均保持不变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM