[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

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

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


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