[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

   1  # Disable various first-time login junki and other annoying stuff.
   2  
   3  use warnings;
   4  use strict;
   5  
   6  # FIXME: Decide which things we actually want to do by default.  For
   7  # now, skip entire script!
   8  exit 0;
   9  
  10  @ARGV == 0
  11      or die "Usage: $0";
  12  
  13  my %reg;
  14  use Win32::TieRegistry (Delimiter => '/', TiedHash => \%reg, qw(REG_DWORD REG_BINARY REG_MULTI_SZ));
  15  
  16  # Replace %VAR% with environment variable VAR in a string.
  17  sub expand_vars ($) {
  18      my ($arg) = @_;
  19  
  20      while ($arg =~ /%([^%]+)%/) {
  21          my $var = $1;
  22          my $val = $ENV{$var};
  23          $val =~ /%/
  24              and die 'Internal error (time to rewrite expand_vars)';
  25          $arg =~ s/%$var%/$val/g;
  26      }
  27  
  28      return $arg;
  29  }
  30  
  31  # Get profiles directory and default user subdirectory
  32  my $profile_list =
  33      'LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList/';
  34  my $profile_list_key = $reg{$profile_list};
  35  defined $profile_list_key
  36      or die "Unable to read $profile_list: $^E";
  37  
  38  my $profiles_dir = $profile_list_key->{'/ProfilesDirectory'};
  39  defined $profiles_dir
  40      or die "Unable to read /ProfilesDirectory: $^E";
  41  $profiles_dir = expand_vars ($profiles_dir);
  42  
  43  my $default_user = $profile_list_key->{'/DefaultUserProfile'};
  44  defined $default_user
  45      or die "Unable to read /DefaultUserProfile: $^E";
  46  
  47  # Get HKEY_CURRENT_USER key
  48  my $cuser_key = $reg{'CUser/'};
  49  
  50  # Get .default user key
  51  my $defuser_key = $reg{'Users/.DEFAULT/'};
  52  
  53  # Get NTUSER.DAT registry hive key
  54  $reg{'/'}->AllowLoad (1)
  55      or die "Unable to enable loading of hive files: $^E";
  56  my $ntuser_dat = "$profiles_dir\\$default_user\\NTUSER.DAT";
  57  my $ntuser_key = $reg{'Users'}->Load ($ntuser_dat, 'NTUSER')
  58      or die "Unable to load registry hive $ntuser_dat: $^E";
  59  
  60  # Setup keys for per-user
  61  
  62  foreach my $reg_key ($cuser_key, $defuser_key, $ntuser_key) {
  63      $reg_key->{'Console/'} = {
  64          # Set scroll buffer to 2000 lines for console
  65          '/ScreenBufferSize' => [ pack('L', 131072080), REG_DWORD ],
  66          # Allow users to use mouse to edit in console
  67          '/QuickEdit' => [ pack('L', 1), REG_DWORD ],
  68      } or die "Unable to set User/Console/ registry settings: $^E";
  69  
  70      $reg_key->{'Control Panel/'} = {
  71          'Desktop/' => {
  72              # Enable killing tasks that don't respond
  73              '/AutoEndTasks' => "1",
  74              # Turn on font smoothing
  75              '/FontSmoothing' => "2",
  76              # Set Font smoothing to standard
  77              '/FontSmoothingType' => [ pack('L', 1), REG_DWORD ],
  78              # Remove tool tips from Min/Max/Close Buttons
  79              '/MinMaxClose' => "0",
  80              # Disable screen saver
  81              '/ScreenSaveActive' => [ pack('L', 0), REG_DWORD ],
  82              # Timeout for responding is 5 seconds
  83              '/WaitToKillAppTimeout' => "5000",
  84              # Don't automatically return to the welcome screen
  85              '/NoAutoReturnToWelcome' => "1",
  86          },
  87          'Keyboard/' => {
  88              # Make windows remember the state of numlock
  89              '/InitialKeyboardIndicators' => "2",
  90          },
  91          'PowerCfg/' => {
  92              # Change power policy to Always On
  93              '/CurrentPowerPolicy' => "3",
  94          },
  95      } or die "Unable to set User/Control Panel/ registry settings: $^E";
  96  
  97      $reg_key->{'Software/'} = {
  98          'Microsoft/' => {
  99              'Command Processor/' => {
 100                  # Change command completion char to TAB
 101                  '/CompletionChar' => [ pack('L', 9), REG_DWORD],
 102                  # Enable command line completion
 103                  '/EnableExtensions' => [ pack('L', 1), REG_DWORD],
 104                  # Change directory completion char to TAB
 105                  '/PathCompletionChar' => [ pack('L', 9), REG_DWORD],
 106                  # Enable UNC paths to be used on the command line
 107                  '/DisableUNCCheck' => [ pack('L', 1), REG_DWORD],
 108              },
 109              'Ftp/' => {
 110                  # Enable pasive FTP
 111                  '/Use PASV' => 'yes',
 112              },
 113              'Internet Explorer/' => {
 114                  'Main/' => {
 115                      # Reuse Internet Explorer windows when possible
 116                      '/AllowWindowReuse' => [ pack('L', 1), REG_DWORD ],
 117                      # Show images the size that they should be
 118                      '/Enable AutoImageResize' => 'no',
 119                      # Don't display errors on page dialog
 120                      '/Error Dlg Displayed On Every Error' => 'no',
 121                      # Don't display errors on page dialog window
 122                      '/Error Dlg Details Pane Open' => 'no',
 123                      # Render screen before drawing
 124                      '/Force Offscreen Composition' => [ pack('L', 1), REG_DWORD ],
 125                      # Don't remember passwords
 126                      '/FormSuggest Passwords' => 'no',
 127                      # Don't prompt to remember passwords
 128                      '/FormSuggest PW Ask' => 'no',
 129                      # Close downloads windows when complete
 130                      '/NotifyDownloadComplete' => 'no',
 131                      # Show Image placeholders
 132                      '/Show Image Placeholders' => [ pack('L', 1), REG_DWORD ],
 133                      # Don't ask to auto fill out forms
 134                      '/Use FormSuggest' => 'no',
 135                      # Don't use search assistant in Internet Explorer
 136                      '/Use Search Asst' => 'no',
 137                  },
 138                  'IntelliForms/' => {
 139                      # Don't ask to auto fill out forms
 140                      '/AskUser' => [ pack('L', 0), REG_DWORD ],
 141                  },
 142              },
 143              'MediaPlayer/' => {
 144                  'Preferences/' => {
 145                      # Don't prompt for Privacy Statement on Media Player
 146                      '/AcceptedPrivacyStatement' => [ pack('L', 1), REG_DWORD],
 147                  },
 148              },
 149              'MessengerService/' => {
 150                  # Don't prompt to create a passport
 151                  '/PassportBalloon' => [ pack('L',0x0a), REG_BINARY ],
 152              },
 153              'Telnet/' => {
 154                  # Enable smoother scrolling in telnet
 155                  '/SmoothScroll' => [ pack('L', 1), REG_DWORD],
 156              },
 157              'Search Assistant/' => {
 158                  # Use classic search for explorer
 159                  '/SocialUI' => [ pack('L', 0), REG_DWORD],
 160                  # Use advanced search dialog
 161                  '/UseAdvancedSearchAlways' => [ pack('L', 1), REG_DWORD],
 162              },
 163              'Windows/' => {
 164                  'CurrentVersion/' => {
 165                      'Applets/' => {
 166                          'Tour/' => {
 167                              # Make windows think we have already seen the tour of windows
 168                              '/RunCount' => [ pack('L', 0), REG_DWORD],
 169                          },
 170                      },
 171                      'Explorer/' => {
 172                          'Advanced/' => {
 173                              # Disable Thumbnail caching
 174                              '/DisableThumbnailCache' => [ pack('L', 1), REG_DWORD ],
 175                              # Display path names correctly
 176                              '/DontPrettyPath' => [ pack('L', 1), REG_DWORD ],
 177                              # Remove popup balloons from tray applications
 178                              #'/EnableBalloonTips' => [ pack('L', 0), REG_DWORD ],
 179                              # Show Hidden and System Files
 180                              '/Hidden' => [ pack('L', 1), REG_DWORD ],
 181                              # Prevent windows from crawling network looking for shares
 182                              '/NoNetCrawling' => [ pack ('L', 1), REG_DWORD],
 183                              # Restore folders on startup
 184                              '/PersistBrowsers' => [ pack('L', 1), REG_DWORD ],
 185                              # Launch explorer windows in separate processes
 186                              '/SeparateProcess' => [ pack('L', 1), REG_DWORD ],
 187                              # Hide really important files needed to boot
 188                              '/ShowSuperHidden' => [ pack('L', 0), REG_DWORD ],
 189                              # Use small icons on start menu
 190                              '/Start_LargeMFUIcons' => [ pack('L', 0), REG_DWORD ],
 191                              # Set number of frequently used programs to 11
 192                              '/Start_MinMFU' => [ pack('L', 11), REG_DWORD ],
 193                              # Don't notify or highlight new applications
 194                              '/Start_NotifyNewApps' => [ pack('L', 0), REG_DWORD ],
 195                              # Don't show My Music on Start Menu
 196                              '/Start_ShowMyMusic' => [ pack('L', 0), REG_DWORD ],
 197                              # Don't show My Pictures on Start Menu
 198                              '/Start_ShowMyPics' => [ pack('L', 0), REG_DWORD ],
 199                              # Show Connect To on Start Menu
 200                              '/Start_ShowNetConn' => [ pack('L', 2), REG_DWORD ],
 201                              # Show Network Places on Start Menu
 202                              '/Start_ShowNetPlaces' => [ pack('L', 1), REG_DWORD ],
 203                              # Show Administrative Tools on All Programs
 204                              '/StartMenuAdminTools' => [ pack('L', 1), REG_DWORD ],
 205                              # Set number of windows for clustering to 5
 206                              '/TaskbarGroupSize' => [ pack('L', 5), REG_DWORD ],
 207                              # Display contents of system folders
 208                              '/WebViewBarricade' => [ pack('L', 1), REG_DWORD ],
 209                          },
 210                          'AutoComplete/' => {
 211                              # Turn on auto completion of commands
 212                              '/Append Completion' => 'yes',
 213                              # Turn on auto suggestion for commands
 214                              '/AutoSuggest' => 'yes',
 215                          },
 216                          'CabinetState/' => {
 217                              # Show full path in title bar for explorer windows
 218                              '/FullPath' => [ pack('L', 1), REG_DWORD ],
 219                              #
 220                              '/Settings' => [ pack('LLL', 0x2000c, 0x77e7011b, 0x60), REG_BINARY ],
 221                              # Use classic search find files and computers
 222                              '/Use Search Asst' => 'no',
 223                          },
 224                          'Desktop/' => {
 225                              'CleanupWiz/' => {
 226                                  # Don't run desktop cleanup wizard
 227                                  '/NoRun' => [ pack('L', 1), REG_DWORD ],
 228                              },
 229                          },
 230                          'HideDesktopIcons/' => {
 231                              'NewStartPanel/' => {
 232                                  # Display My Network Places on Desktop
 233                                  '/{208D2C60-3AEA-1069-A2D7-08002B30309D}' => [ pack('L', 0), REG_DWORD ],
 234                                  # Display My Computer on Desktop
 235                                  '/{20D04FE0-3AEA-1069-A2D8-08002B30309D}' => [ pack('L', 0), REG_DWORD ],
 236                                  # Display My Documents on Desktop
 237                                  '/{450D8FBA-AD25-11D0-98A8-0800361B1103}' => [ pack('L', 0), REG_DWORD ],
 238                                  # Display Internet Explorer on Desktop
 239                                  '/{871C5380-42A0-1069-A2EA-08002B30309D}' => [ pack('L', 0), REG_DWORD ],
 240                              },
 241                          },
 242                          # Don't prefix shortcuts with "Shortcut to.."
 243                          '/Link' => [ pack('L', 0), REG_BINARY ],
 244                          'SmallIcons/' => {
 245                              # Show Small Icons in Internet Explorer
 246                              '/SmallIcons' => 'yes',
 247                          },
 248                      },
 249                      'Internet Settings/' => {
 250                          '5.0/' => {
 251                              'Cache/' => {
 252                                  'Content/' => {
 253                                      # Only cache 100Mb of internet pages
 254                                      '/CacheLimit' => [ pack('L', 102400), REG_DWORD ],
 255                                  },
 256                              },
 257                          },
 258                          'Cache/' => {
 259                              # Empty Temporary Internet Files when browser exits
 260                              '/Persistent' => [ pack('L', 0), REG_DWORD ],
 261                          },
 262                          # Don't cache Encrypted pages
 263                          '/DisableCachingOfSSLPages' => [ pack('L', 1), REG_DWORD ],
 264                          # Don't show privacy reminder
 265                          '/PrivDiscUiShown' => [ pack('L', 1), REG_DWORD ],
 266                          # Check for newer of page on every visit
 267                          '/SyncMode5' => [ pack('L', 3), REG_DWORD ],
 268                          # Don't warn when crossing from http to https
 269                          '/WarnOnZoneCrossing' => [ pack('L', 0), REG_DWORD ],
 270                          'Zones/' => {
 271                              '3/' => {
 272                                  # Don't prompt on form submission
 273                                  '/1601' => [ pack('L', 0), REG_DWORD ],
 274                              },
 275                          },
 276                      },
 277                      'Policies/Explorer/' => {
 278                          # Don't include machine name in shortcuts
 279                          '/LinkResolveIgnoreLinkInfo' => [ pack('L', 0), REG_DWORD ],
 280                          # Don't do an exaustive search if lnk is broken
 281                          '/NoResolveSearch' => [ pack('L', 1), REG_DWORD ],
 282                          # Don't create shared document area
 283                          '/NoSharedDocuments' => [ pack('L', 1), REG_DWORD ],
 284                      },
 285                      'UnreadMail/' => {
 286                          # Don't display count of unread mail
 287                          '/MessageExpiryDays' => [ pack('L', 0), REG_DWORD ],
 288                      },
 289                  },
 290                  'ShellNoRoam/' => {
 291                      'DUIBags/' => {
 292                          'ShellFolders/' => {
 293                              '{00021400-0000-0000-C000-000000000046}/' => {
 294                                  # Expand Details panel for Desktop
 295                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 296                              },
 297                              '{208D2C60-3AEA-1069-A2D7-08002B30309D}/' => {
 298                                  # Expand Details panel for Network Places
 299                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 300                              },
 301                              '{20D04FE0-3AEA-1069-A2D8-08002B30309D}/' => {
 302                                  # Expand Details panel for My Computer
 303                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 304                              },
 305                              '{450D8FBA-AD25-11D0-98A8-0800361B1103}/' => {
 306                                  # Expand Details panel for My Documents
 307                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 308                              },
 309                              '{7007ACC7-3202-11D1-AAD2-00805FC1270E}/' => {
 310                                  # Expand Details panel for Network Connections
 311                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 312                              },
 313                              '{C0542A90-4BF0-11D1-83EE-00A0C90DC849}/' => {
 314                                  # Expand Details panel for Other Computers
 315                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 316                              },
 317                              '{E88DCCE0-B7B3-11D1-A9F0-00AA0060FA31}/' => {
 318                                  # Expand Details panel for Compressed Folder
 319                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 320                              },
 321                              '{F3364BA0-65B9-11CE-A9BA-00AA004AE837}/' => {
 322                                  # Expand Details panel for System Folder
 323                                  '/ExpandDetailsTasks' => [ pack('L', 1), REG_DWORD ],
 324                              },
 325                          },
 326                      },
 327                  },
 328              },
 329          },
 330      } or die "Unable to set User/Software/Microsoft/ registry settings: $^E";
 331  
 332      # Remove all Post Boot Reminders
 333      foreach my $reminder ( keys( %{$reg_key->{'Software/Microsoft/Windows/CurrentVersion/Explorer/PostBootReminders/'}} ) ) {
 334          delete $reg_key->{'Software/Microsoft/Windows/CurrentVersion/Explorer/PostBootReminders/'.$reminder};
 335      }
 336      delete $reg_key->{'Software/Microsoft/Windows/CurrentVersion/Explorer/PostBootReminders/'};
 337  
 338      # Set Screen Saver to None
 339      delete $reg_key->{'Control Panel/Desktop//SCRNSAVE.EXE'};
 340  
 341      # Add ODBC panel to Control Panel
 342      delete $reg_key->{'Control Panel/don\'t load/odbccp32.cpl'};
 343  }
 344  
 345  # Setup keys for machine
 346  
 347  $reg{'Classes'}->{'CLSID'} = {
 348      '{450D8FBA-AD25-11D0-98A8-0800361B1103}/' => {
 349          # Make My Computer the first icon
 350          '/SortOrderIndex' => [ pack('L', 84), REG_DWORD],
 351      },
 352  } or die "Unable to set Classes/CLSID/ registry settings: $^E";
 353  
 354  $reg{'LMachine'}->{'Software/'} = {
 355      'Classes/' => {
 356          'Software/' => {
 357              'Microsoft/' => {
 358                  'MediaPlayer/' => {
 359                      'Preferences/' => {
 360                          # Don't prompt for EULA on Media Player
 361                          '/AcceptedEULA' => [ pack('L', 1), REG_DWORD],
 362                      },
 363                  },
 364              },
 365          },
 366      },
 367      'Microsoft/' => {
 368          'Command Processor/' => {
 369              # Change command completion char to TAB
 370              '/CompletionChar' => [ pack('L', 9), REG_DWORD],
 371              # Enable command line completion
 372              '/EnableExtensions' => [ pack('L', 1), REG_DWORD],
 373              # Change directory completion char to TAB
 374              '/PathCompletionChar' => [ pack('L', 9), REG_DWORD],
 375          },
 376          'Windows/' => {
 377              'CurrentVersion/' => {
 378                  'Applets/' => {
 379                      'Tour/' => {
 380                          # Make windows think we have already seen the tour of windows
 381                          '/RunCount' => [ pack('L', 0), REG_DWORD ],
 382                      },
 383                  },
 384                  'Explorer/' => {
 385                      'Advanced/' => {
 386                          # Prevent windows from crawling network looking for shares
 387                          '/NoNetCrawling' => [ pack('L', 1), REG_DWORD ],
 388                      },
 389                      'AlwaysUnloadDLL/' => {
 390                          # Unload DLL's once all applications using them are done
 391                          '/' => "1",
 392                      },
 393                      # Show drive letters first on shares
 394                      '/ShowDriveLettersFirst' => [ pack('L', 1), REG_DWORD ],
 395                  },
 396                  'UnreadMail/' => {
 397                      # Don't display count of unread mail
 398                      '/MessageExpiryDays' => [ pack('L', 0), REG_DWORD ],
 399                  },
 400              },
 401          },
 402          'Windows NT/' => {
 403              'CurrentVersion/' => {
 404                  'WinLogon/' => {
 405                      # Disable Fast User Switching
 406                      '/AllowMultipleTSSessions' => [ pack('L', 0), REG_DWORD ],
 407                      # Disable Welcome screen (with the list of users)
 408                      '/LogonType' => [ pack('L', 0), REG_DWORD ],
 409                  },
 410              },
 411          },
 412      },
 413      'Policies/' => {
 414          'Microsoft/' => {
 415              'Windows/' => {
 416                  'Installer/' => {
 417                      # Enable administrators to install appliations over Terminal Services
 418                      '/EnableAdminTSRemote' => [ pack('L', 1), REG_DWORD ],
 419                  },
 420              },
 421          },
 422      },
 423  } or die "Unable to set LMachine/Software/ registry settings: $^E";
 424  
 425  $reg{'LMachine'}->{'System/'} = {
 426      'CurrentControlSet/' => {
 427          'Control/' => {
 428              'ContentIndex/' => {
 429                  # Find text in all files, not just known ones
 430                  '/FilterFilesWithUnknownExtensions' => [ pack('L', 1), REG_DWORD ],
 431              },
 432              'FileSystem/' => {
 433                  # Disable NTFS Last Access updates
 434                  '/NtfsDisableLastAccessUpdate' => [ pack('L', 1), REG_DWORD ],
 435              },
 436              'Lsa/' => {
 437                  # Disable simple filesharing
 438                  '/ForceGuest' => [ pack('L', 0), REG_DWORD ],
 439              },
 440              'Print/' => {
 441                  # Don't announce printers to other servers
 442                  '/DisableServerThread' => [ pack('L', 1), REG_DWORD ],
 443              },
 444              'Tcpip/' => {
 445                  # Disable dynamic DNS updates
 446                  '/DisableDynamicUpdate' => [ pack('L', 1), REG_DWORD ],
 447                  # Don't autoconfigure IP if DHCP not found
 448                  '/IPAutoconfigurationEnabled' => [ pack('L', 0), REG_DWORD ],
 449              },
 450          },
 451      },
 452  } or die "Unable to set LMachine/System/CurrentControlSet/ registry settings: $^E";
 453  
 454  # Show icon in taskbar for network interfaces
 455  foreach my $networkadapter (keys( %{$reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'}} )) {
 456      if ( defined $reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'.$networkadapter.'Connection/'} ) {
 457          $reg{'LMachine/System/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}/'.$networkadapter} = {
 458              'Connection/' => {
 459                  '/ShowIcon' => [ pack('L', 1), REG_DWORD],
 460               },
 461          };
 462      }
 463  }
 464  
 465  # Change CdRom letter to R: and update setup paths
 466  foreach my $mounts ( grep( /:$/, keys( %{$reg{'LMachine/System/MountedDevices/'}} ) ) ) {
 467      if ( $reg{'LMachine/System/MountedDevices/'.$mounts} =~ /[Cc].[Dd].[Rr].[Oo].[Mm]/ ) {
 468          my $oldcdrom = delete $reg{'LMachine/System/MountedDevices/'.$mounts};
 469          $reg{'LMachine/System/MountedDevices//\\DosDevices\\R:'} = [ $oldcdrom, REG_BINARY ];
 470          $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//Installation Sources'} = [ ['R:\\i386'], REG_MULTI_SZ ];
 471          $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//ServicePackSourcePath'} = 'R:\\';
 472          $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Setup//SourcePath'} = 'R:\\';
 473          last;
 474      }
 475  }
 476  
 477  # Don't browse for Scheduled Tasks in Network Neighborhood
 478  delete $reg{'LMachine/Software/Microsoft/Windows/CurrentVersion/Explorer/RemoteComputer/NameSpace/{D6277990-4C6A-11CF-8D87-00AA0060F5BF}/'};
 479  
 480  exit 0;


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