WinSys - Python tools for the Windows Administrator

We read the Windows docs so you don’t have to

Introduction

WinSys is a Python package which wraps aspects of the Windows API to make them more Pythonic and usable by Windows administrators directly from the interpreter or as part of a wider set of applications. It targets recent versions of Python and reasonably recent versions of Windows.

It is unashamedly platform-specific: no hint of a concession towards more Unix-like operating systems. You can read about the design philosophy and decisions in About WinSys. If you want to see some examples, have a look in the Cookbook.

WinSys is developed as an Open Source project and the project home, together with issues list and browseable source code is at:

If you’re interested in helping with the project let me know and I’ll add you to the project members list.

Example

Copy a registry key from HKLM to HKCU and set its permissions so that only the current user has change access while everyone else gets read. Then dump the details of the new top-level key, including its security.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from __future__ import with_statement
from winsys import registry, accounts

new_key = registry.copy(r"HKLM\Software\Python", r"HKLM\Software\WinsysPython")

try:
    with new_key.security() as sec:
        sec.break_inheritance(copy_first=False)
        sec.dacl += [
           ("Users", "R", "ALLOW"),
           (accounts.me(), "F", "ALLOW"),
        ]
        sec.dump()

finally:
    print "***"
    new_key.security().dump()

This example makes use of the registry, accounts and security modules. You can see discussion of this example and more in the Cookbook.

Download

  • pip:

    pip install winsys
    
  • Git master:

    git clone git://github.com/tjguk/winsys.git
    

    and then, from within that clone:

    pip install -e .[all]