[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-logonpy/usr/share/se3/logonpy_Win9x/ -> se3Reg.py (source)

   1  # -*- coding: utf-8 -*-
   2  import sys, os, posix
   3  from se3Utils import *
   4  try:
   5      sys.path.append('/etc/se3/python/')
   6      from  logoncfg import *
   7  except: pass
   8  
   9  class se3Reg:
  10  
  11      def __init__ (self, path2BatFiles, computer):
  12          """
  13              Open vbs registry rules, some initializations
  14          """
  15          try:
  16              self.__vbs = open ("%s/%s.vbs" % (path2BatFiles, computer), 'w')
  17              self.__computer = computer
  18              self.__vbsContent = []
  19  
  20              # Add some helpers
  21              if os.access ("/etc/se3/python/logonReg.vbs", os.F_OK):
  22                  file = open ("/etc/se3/python/logonReg.vbs")
  23                  for line in file.xreadlines ():
  24                      self.__vbsContent.append (line)
  25  
  26              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\AppData\", \"K:\profil\\appdata\", \"REG_EXPAND_SZ\"\r\n")
  27              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop\", \"K:\profil\Bureau\", \"REG_EXPAND_SZ\"\r\n")
  28              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal\", \"K:\Docs\", \"REG_EXPAND_SZ\"\r\n")
  29              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Programs\", \"K:\profil\Demarrer\Programmes\", \"REG_EXPAND_SZ\"\r\n")
  30              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Start Menu\", \"K:\profil\Demarrer\", \"REG_EXPAND_SZ\"\r\n")
  31              self.__vbsContent.append ("oWsh.RegWrite \"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup\", \"K:\profil\Demarrer\Programmes\Démarrage\", \"REG_EXPAND_SZ\"\r\n")
  32              
  33          except OSError:
  34             print "Can't write %s vbs in %s.vbs" % computer
  35             sys.exit (1)
  36  
  37  
  38      def __del__ (self):
  39          """
  40              Force some keys, write vbs, Delete some keys, close vbs
  41          """
  42          try:
  43              for line in self.__vbsContent:
  44                  self.__vbs.write (line)
  45              self.__vbs.close ()
  46  
  47          except OSError:
  48              print "Can't write %s vbs in %s.vbs" % self.__computer
  49  
  50  
  51      def addRest (self, restrictions):
  52          """
  53              Add reg rules to vbs file
  54          """
  55          try:
  56              for rest in restrictions:
  57                  if rest[3] != "SUPPR":
  58                      if rest[1] == "REG_DWORD":
  59                          self.__vbsContent.append ("oWsh.RegWrite \"%s\", CLng(%s), \"REG_DWORD\"\r\n" % (rest[0], rest[3]))
  60                      else:
  61                          self.__vbsContent.append ("oWsh.RegWrite \"%s\", \"%s\", \"%s\"\r\n" % (rest[0], rest[3], rest[1]))
  62                  else:
  63                      self.__vbsContent.append ("oWsh.RegDelete \"%s\"\r\n" % rest[0])   
  64      
  65          except OSError:
  66              print "Can't write %s vbs in %s.vbs" % self.__computer


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1