[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/bin/ -> win2ksp4-notips.pl (source)

   1  # Disable various first-time login junk.
   2  
   3  use warnings;
   4  use strict;
   5  
   6  @ARGV == 0
   7      or die "Usage: $0";
   8  
   9  my %reg;
  10  use Win32::TieRegistry (Delimiter => '/', TiedHash => \%reg, qw(REG_DWORD REG_BINARY REG_MULTI_SZ));
  11  
  12  # Replace %VAR% with environment variable VAR in a string.
  13  sub expand_vars ($) {
  14      my ($arg) = @_;
  15  
  16      while ($arg =~ /%([^%]+)%/) {
  17          my $var = $1;
  18          my $val = $ENV{$var};
  19          $val =~ /%/
  20              and die 'Internal error (time to rewrite expand_vars)';
  21          $arg =~ s/%$var%/$val/g;
  22      }
  23  
  24      return $arg;
  25  }
  26  
  27  # Get profiles directory and default user subdirectory
  28  my $profile_list =
  29      'LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList/';
  30  my $profile_list_key = $reg{$profile_list};
  31  defined $profile_list_key
  32      or die "Unable to read $profile_list: $^E";
  33  
  34  my $profiles_dir = $profile_list_key->{'/ProfilesDirectory'};
  35  defined $profiles_dir
  36      or die "Unable to read /ProfilesDirectory: $^E";
  37  $profiles_dir = expand_vars ($profiles_dir);
  38  
  39  my $default_user = $profile_list_key->{'/DefaultUserProfile'};
  40  defined $default_user
  41      or die "Unable to read /DefaultUserProfile: $^E";
  42  
  43  # Get HKEY_CURRENT_USER key
  44  my $cuser_key = $reg{'CUser/'};
  45  
  46  # Get .default user key
  47  my $defuser_key = $reg{'Users/.DEFAULT/'};
  48  
  49  # Get NTUSER.DAT registry hive key
  50  $reg{'/'}->AllowLoad (1)
  51      or die "Unable to enable loading of hive files: $^E";
  52  my $ntuser_dat = "$profiles_dir\\$default_user\\NTUSER.DAT";
  53  my $ntuser_key = $reg{'Users'}->Load ($ntuser_dat, 'NTUSER')
  54      or die "Unable to load registry hive $ntuser_dat: $^E";
  55  
  56  # Setup keys for per-user
  57  
  58  foreach my $reg_key ($cuser_key, $defuser_key, $ntuser_key) {
  59      $reg_key->{'Console/'} = {
  60          # Set scroll buffer to 2000 lines for console
  61  #        '/ScreenBufferSize' => [ pack('L', 131072080), REG_DWORD ],
  62          # Allow users to use mouse to edit in console
  63  #        '/QuickEdit' => [ pack('L', 1), REG_DWORD ],
  64      } or die "Unable to set User/Console/ registry settings: $^E";
  65  
  66      $reg_key->{'Control Panel/'} = {
  67          'Desktop/' => {
  68              # Enable killing tasks that don't respond
  69  #            '/AutoEndTasks' => "1",
  70              # Turn on font smoothing
  71  #            '/FontSmoothing' => "2",
  72              # Disable screen saver
  73  #            '/ScreenSaveActive' => [ pack('L', 0), REG_DWORD ],
  74              # Timeout for responding is 5 seconds
  75  #            '/WaitToKillAppTimeout' => "5000",
  76          },
  77          'Keyboard/' => {
  78              # Make windows remember the state of numlock
  79  #            '/InitialKeyboardIndicators' => "2",
  80          },
  81          'PowerCfg/' => {
  82              # Change power policy to Always On
  83  #            '/CurrentPowerPolicy' => "3",
  84          },
  85      } or die "Unable to set User/Control Panel/ registry settings: $^E";
  86  
  87      $reg_key->{'Software/'} = {
  88          'Microsoft/' => {
  89              'Command Processor/' => {
  90                  # Enable UNC paths to be used on the command line
  91  #                '/DisableUNCCheck' => [ pack('L', 1), REG_DWORD],
  92              },
  93              'Ftp/' => {
  94                  # Enable pasive FTP
  95  #                '/Use PASV' => 'yes',
  96              },
  97              'Internet Connection Wizard/' => {
  98                  # Disable Internet Connection Wizard
  99                  '/Completed' => [ pack('L', 1), REG_BINARY ],
 100              },
 101              'Internet Explorer/' => {
 102                  'Main/' => {
 103                      # Reuse Internet Explorer windows when possible
 104  #                    '/AllowWindowReuse' => [ pack('L', 1), REG_DWORD ],
 105                      # Show images the size that they should be
 106  #                    '/Enable AutoImageResize' => 'no',
 107                      # Don't display errors on page dialog
 108  #                    '/Error Dlg Displayed On Every Error' => 'no',
 109                      # Don't display errors on page dialog window
 110  #                    '/Error Dlg Details Pane Open' => 'no',
 111                      # Render screen before drawing
 112  #                    '/Force Offscreen Composition' => [ pack('L', 1), REG_DWORD ],
 113                      # Don't remember passwords
 114  #                    '/FormSuggest Passwords' => 'no',
 115                      # Don't prompt to remember passwords
 116  #                    '/FormSuggest PW Ask' => 'no',
 117                      # Close downloads windows when complete
 118  #                    '/NotifyDownloadComplete' => 'no',
 119                      # Show Image placeholders
 120  #                    '/Show Image Placeholders' => [ pack('L', 1), REG_DWORD ],
 121                      # Don't ask to auto fill out forms
 122  #                    '/Use FormSuggest' => 'no',
 123                      # Don't use search assistant in Internet Explorer
 124  #                    '/Use Search Asst' => 'no',
 125                  },
 126                  'IntelliForms/' => {
 127                      # Don't ask to auto fill out forms
 128  #                    '/AskUser' => [ pack('L', 0), REG_DWORD ],
 129                  },
 130              },
 131              'MediaPlayer/' => {
 132                  'Preferences/' => {
 133                      # Don't prompt for Privacy Statement on Media Player
 134                      '/AcceptedPrivacyStatement' => [ pack('L', 1), REG_DWORD],
 135                  },
 136              },
 137              'Telnet/' => {
 138                  # Enable smoother scrolling in telnet
 139  #                '/SmoothScroll' => [ pack('L', 1), REG_DWORD],
 140              },
 141              'Windows/' => {
 142                  'CurrentVersion/' => {
 143                      'Explorer/' => {
 144                          'Advanced/' => {
 145                              # Disable Thumbnail caching
 146  #                            '/DisableThumbnailCache' => [ pack('L', 1), REG_DWORD ],
 147                              # Display path names correctly
 148  #                            '/DontPrettyPath' => [ pack('L', 1), REG_DWORD ],
 149                              # Show Hidden and System Files
 150  #                            '/Hidden' => [ pack('L', 1), REG_DWORD ],
 151                              # Restore folders on startup
 152  #                            '/PersistBrowsers' => [ pack('L', 1), REG_DWORD ],
 153                              # Launch explorer windows in separate processes
 154  #                            '/SeparateProcess' => [ pack('L', 1), REG_DWORD ],
 155                              # Display contents of system folders
 156  #                            '/WebViewBarricade' => [ pack('L', 1), REG_DWORD ],
 157                              # always show full startmenue
 158  #                            '/IntelliMenus' => 'no',                            
 159                          },
 160                          'AutoComplete/' => {
 161                              # Turn on auto completion of commands
 162  #                            '/Append Completion' => 'yes',
 163                              # Turn on auto suggestion for commands
 164  #                            '/AutoSuggest' => 'yes',
 165                          },
 166                          'CabinetState/' => {
 167                              # Show full path in title bar for explorer windows
 168  #                            '/FullPath' => [ pack('L', 1), REG_DWORD ],
 169                          },
 170                          # Don't prefix shortcuts with "Shortcut to.."
 171  #                        '/Link' => [ pack('L', 0), REG_BINARY ],
 172                          'SmallIcons/' => {
 173                              # Show Small Icons in Internet Explorer
 174  #                            '/SmallIcons' => 'yes',
 175                          },
 176                          'Tips/' => {
 177                              # Disable tips
 178                              '/Show' => [ pack('L', 0), REG_DWORD ],
 179                          },
 180                      },
 181                      'Internet Settings/' => {
 182                          '5.0/' => {
 183                              'Cache/' => {
 184                                  'Content/' => {
 185                                      # Only cache 100Mb of internet pages
 186  #                                    '/CacheLimit' => [ pack('L', 102400), REG_DWORD ],
 187                                  },
 188                              },
 189                          },
 190                          'Cache/' => {
 191                              # Empty Temporary Internet Files when browser exits
 192  #                            '/Persistent' => [ pack('L', 0), REG_DWORD ],
 193                          },
 194                          # Don't cache Encrypted pages
 195  #                        '/DisableCachingOfSSLPages' => [ pack('L', 1), REG_DWORD ],
 196                          # Don't show privacy reminder
 197  #                        '/PrivDiscUiShown' => [ pack('L', 1), REG_DWORD ],
 198                          # Check for newer of page on every visit
 199  #                        '/SyncMode5' => [ pack('L', 3), REG_DWORD ],
 200                          # Don't warn when crossing from http to https
 201  #                        '/WarnOnZoneCrossing' => [ pack('L', 0), REG_DWORD ],
 202                          'Zones/' => {
 203                              '3/' => {
 204                                  # Don't prompt on form submission
 205  #                                '/1601' => [ pack('L', 0), REG_DWORD ],
 206                              },
 207                          },
 208                      },
 209                      'Policies/Explorer/' => {
 210                          # Don't include machine name in shortcuts
 211  #                        '/LinkResolveIgnoreLinkInfo' => [ pack('L', 0), REG_DWORD ],
 212                          # Don't do an exaustive search if lnk is broken
 213  #                        '/NoResolveSearch' => [ pack('L', 1), REG_DWORD ],
 214                      },
 215                  },
 216              },
 217          },
 218      } or die "Unable to set User/Software/Microsoft/ registry settings: $^E";
 219  
 220      # Set Screen Saver to None
 221  #    delete $reg_key->{'Control Panel/Desktop//SCRNSAVE.EXE'};
 222  
 223      # Don't run Internet Connection Wizard
 224      delete $reg_key->{'Software/Microsoft/Windows/CurrentVersion/RunOnce//^SetupICWDesktop'};
 225  }
 226  
 227  # Setup keys for machine
 228  
 229  $reg{'LMachine'}->{'Software/'} = {
 230      'Classes/' => {
 231          'Software/' => {
 232              'Microsoft/' => {
 233                  'MediaPlayer/' => {
 234                      'Preferences/' => {
 235                          # Don't prompt for EULA on Media Player
 236                          '/AcceptedEULA' => [ pack('L', 1), REG_DWORD],
 237                      },
 238                  },
 239              },
 240          },
 241      },
 242      'Microsoft/' => {
 243          'Windows/' => {
 244              'CurrentVersion/' => {
 245                  'Explorer/' => {
 246                      'AlwaysUnloadDLL/' => {
 247                          # Unload DLL's once all applications using them are done
 248  #                        '/' => "1",
 249                      },
 250                      # Show drive letters first on shares
 251  #                    '/ShowDriverLettersFirst' => [ pack('L', 1), REG_DWORD ],
 252                  },
 253              },
 254          },
 255      },
 256      'Policies/' => {
 257          'Microsoft/' => {
 258              'Windows/' => {
 259                  'Installer/' => {
 260                      # Enable administrators to install applications over Terminal Services
 261  #                    '/EnableAdminTSRemote' => [ pack('L', 1), REG_DWORD ],
 262                  },
 263              },
 264          },
 265      },
 266  } or die "Unable to set LMachine/Software/ registry settings: $^E";
 267  
 268  $reg{'LMachine'}->{'System/'} = {
 269      'CurrentControlSet/' => {
 270          'Control/' => {
 271              'FileSystem/' => {
 272                  # Disable NTFS Last Access updates
 273  #                '/NtfsDisableLastAccessUpdate' => [ pack('L', 1), REG_DWORD ],
 274              },
 275          },
 276          'Services/' => {
 277              'KSecDD/' => {
 278                  # Don't show start button balloon tip
 279                  '/StartButtonBalloonTip' => [ pack('L', 1), REG_DWORD ],
 280              },
 281          },
 282      },
 283  } or die "Unable to set LMachine/System/CurrentControlSet/ registry settings: $^E";
 284  
 285  # Show icon in taskbar for network interfaces
 286  foreach my $networkadapter (keys( %{$reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'}} )) {
 287      if ( defined $reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'.$networkadapter.'Connection/'} ) {
 288          $reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'.$networkadapter} = {
 289              'Connection/' => {
 290  #                '/ShowIcon' => [ pack('L', 1), REG_DWORD],
 291               },
 292          };
 293      }
 294  }
 295  
 296  # Change CdRom letter to R: and update setup paths
 297  foreach my $mounts ( grep( /:$/, keys( %{$reg{'LMachine/System/MountedDevices/'}} ) ) ) {
 298      if ( $reg{'LMachine/System/MountedDevices/'.$mounts} =~ /[Cc].[Dd].[Rr].[Oo].[Mm]/ ) {
 299          my $oldcdrom = delete $reg{'LMachine/System/MountedDevices/'.$mounts};
 300  #        $reg{'LMachine/System/MountedDevices//\\DosDevices\\R:'} = [ $oldcdrom, REG_BINARY ];
 301  #        $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//Installation Sources'} = [ ['R:\\i386'], REG_MULTI_SZ ];
 302  #        $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//ServicePackSourcePath'} = 'R:\\';
 303  #        $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//SourcePath'} = 'R:\\';
 304          last;
 305      }
 306  }
 307  
 308  # Don't browse for Scheduled Tasks in Network Neighborhood
 309  #delete $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Explorer/RemoteComputer/NameSpace/{D6277990-4C6A-11CF-8D87-00AA0060F5BF}/'};
 310  
 311  exit 0;


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