質問

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. 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. When executing this, the return is:

vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool (C) Copyright 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?

Follow-up: using MBu as a jumping off point I found that the following command does the trick:

os.system('%systemroot%\\sysnative\\cmd.exe /c vssadmin list writers > x:\\foo\\vss.txt')
役に立ちましたか?

解決

Under Windows 2008 or newer you can launch 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. 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.

他のヒント

Launch C:\Windows\SysWOW64\vssadmin.exe explicitly to always get the 64-bit version.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top