tis-xpconfig 3

  • package : tis-xpconfig
  • version : 3
  • description : Configuration de base XP Active RDP avec fw Theme classique CMD avec edition rapide disable roaming profile disable offline Disable browser choice icon windows explorer settings (voir extensions, ...)
  • maintainer : TIS <technique@tranquil-it-systems.fr>
  • date : 2017-07-20 11:25:30
  • Depends :

setup.py

# -*- coding: UTF-8 -*-
from setuphelpers import *
import os
import glob
import tempfile
import platform

from _winreg import *

uninstallkey=[]

explorer_settings = """\
Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\ThemeManager]
"WCreatedUser"="1"
"ThemeActive"="0"

[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer]
"SearchSystemDirs"=dword:00000001
"SearchHidden"=dword:00000001
"IncludeSubFolders"=dword:00000001
"CaseSensitive"=dword:00000000
"SearchSlowFiles"=dword:00000001
"WebView"=dword:00000000
"EnableAutoTray"=dword:00000000

[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"TaskbarSizeMove"=dword:00000001
"TaskbarGroupSize"=dword:00000000
"HideFileExt"=dword:00000000
"WebView"=dword:00000000
"WebViewBarricade"=dword:00000001

[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState]
"Settings"=hex:0c,00,02,00,0b,01,f1,75,60,00,00,00
"FullPath"=dword:00000001
"FullPathAddress"=dword:00000001

[HKEY_USERS\.DEFAULT\Software\Microsoft\Search Assistant]
"SocialUI"=dword:00000000
"UseAdvancedSearchAlways"=dword:00000001

[HKEY_USERS\.DEFAULT\Console\%SystemRoot%_system32_cmd.exe]
"QuickEdit"=dword:00000800
"ScreenBufferSize"=dword:012c00a0
"WindowSize"=dword:001900a0
"HistoryNoDup"=dword:00000000

[HKEY_USERS\.DEFAULT\Control Panel\Desktop]
"Wallpaper"=""

"""

def set_key(regpath):
    try:
        reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
    except EnvironmentError:
        try:
            reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print "*** Unable to register!"
            return

def set_registry_value(path,name,value):
    """Modify registry with regedit style type:value
      type can be REG_SZ or REG_DWORD
      don't manage Wow6432Node redirection problem on win64
    """
    hivestring = path.split('\\')[0]
    hive=0
    if hivestring in ('HKEY_LOCAL_MACHINE','HKLM'):
        hive =HKEY_LOCAL_MACHINE
    elif hivestring in ('HKEY_CURRENT_USER','HKCU'):
        hive =HKEY_CURRENT_USER
    elif hivestring in ('HKEY_USERS',):
        hive =HKEY_USERS
    elif hivestring in ('HKEY_CLASSES_ROOT',):
        hive =HKEY_CLASSES_ROOT
    elif hivestring in ('HKEY_CURRENT_CONFIG',):
        hive =HKEY_CURRENT_CONFIG
    if hive==0:
        raise Exception("hive type not yet supported : " + hivestring)
    regpath = "\\".join(path.split('\\')[1:])
    REG_type_string=value.split(':')[0]
    reg_type=0
    if REG_type_string=='REG_SZ':
        reg_type =REG_SZ
        key_value=value.split(':')[1]
    if REG_type_string=='REG_DWORD':
        reg_type = REG_DWORD
        key_value = int(value.split(':')[1],16)
    if reg_type==0:
        raise Exception("reg type " + REG_type_string + " not yet supported")
    try:
        key = OpenKey(hive, regpath,0,KEY_SET_VALUE)
    except:
        key = CreateKey(hive, regpath)
    SetValueEx(key, name, 0,reg_type, key_value)
    CloseKey(key)

def install():
    if platform.win32_ver()[0]<>'XP':
        raise Exception('Only for Windows XP !')
    print ("[Registry_OfflineFileDisable]")
    set_registry_value('HKLM\SYSTEM\CurrentControlSet\Services\MRxSmb\Parameters',
                'CscEnabled','REG_DWORD:00000000')

    print ("[Registry_DisableRoamingProfile]")
    set_registry_value('HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System',
            "LocalProfile",'REG_DWORD:00000001')

    print ("[Registry_enable_rdp]")
    set_registry_value('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server',
        "fDenyTSConnections",'REG_DWORD:00000000')

    ##########
    print ('Disable browser choice icon')
    set_registry_value('HKEY_LOCAL_MACHINE\Software\BrowserChoice','Enable',"REG_DWORD:00000000")
    set_registry_value('HKEY_LOCAL_MACHINE\Software\BrowserChoice','Shortcut','REG_DWORD:00000000')
    # delete file C:\Users\Public\Desktop\Browser Choice.lnk
    link_list = glob.glob(makepath(common_desktop(),'Choix de navigateur*'))
    for link in link_list:
        os.remove(link)

    print ("enabling firewall support")
    run('sc config sharedaccess start= auto')
    if not service_is_running('sharedaccess'):
        service_start('sharedaccess')
    run('netsh.exe firewall set opmode mode=enable profile=all')
    print("Remove opsi firewall exception for port 4441")
    run('netsh.exe firewall delete portopening tcp 4441')
    print ("opening port 3389 for rdp")
    run('netsh.exe firewall set portopening tcp 3389 rdp enable all')
    print ("enabling ping request")
    run('netsh.exe firewall set icmpsetting 8 enable')

    print ("[Registry_hide_internet_explorer_icon]")
    set_registry_value('HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\HideMyComputerIcons',
        '{21EC2020-3AEA-1069-A2DD-08002B30309D}','REG_DWORD:00000001')
    session_setup()

def session_setup():
    if platform.win32_ver()[0]<>'XP':
        raise Exception('Only for Windows XP !')
    print "Set desktop settings for default user"
    reg = tempfile.NamedTemporaryFile(suffix='.reg',delete=False)
    with reg:
        reg.write(explorer_settings.replace(r'HKEY_USERS\.DEFAULT',r'HKEY_CURRENT_USER') )
    run('reg import "%s"' % reg.name)
    remove_file(reg.name)



    

manifest.sha1

[["setup.py", "43485f323a9914bd3b8c52c9b282cc228de15f2c"], ["WAPT/certificate.crt", "0db563dc9077b268ca07ba834322d0fc5e21f8e5"], ["WAPT/wapt.psproj", "50994be46d7b031d04ab16ef781382f63e92e2e5"], ["WAPT/control", "511e6254e62c87a1c928c1de3efc33f78f37c253"]]