############################################################################## # John McKee # 6/01/2001 # # GenericReg Edits Version 1 # # Files: # 1. Genericreg.pl # 2. Regentry.pm # 3. Reglist.pm # # Standard Registry Edits # 1. Command Prompt from Explorer # 2. Personalized Bitmap at Logon # 3. Don't Display Last User at Logon # # Build Perl version 5.6.1 # # Contents Genericreg.pl: # 1. Gui # 2. 6 Subfunctions for registry edits # ############################################################################## use Tk; use Tk::Menubutton; use Tk::Canvas; use Win32::Registry; use regentry; use reglist; my ($hkey,$SubKey); $call_entry = regentry->new(); $call_list = reglist->new(); gui(); ################################################################################### #GUI ################################################################################### sub gui { my $top = MainWindow->new(); $top->title('Generic Registry Edits'); #menubar frame widget $menu = $top->Frame(-relief=>"raised", -borderwidth=>2); #end menubar #pulldowns in menubar $menu_pulldown1 = $menu->Menubutton(-text=>"File", -underline=>0); $menu_pulldown2 = $menu->Menubutton(-text=>"Custom", -underline=>0); #end pulldowns #pulldown commands for file menu # $menu_pulldown1->command(-label=>"Open", -command=>sub{open_choice()}); # $menu_pulldown1->separator(); $menu_pulldown1->command(-label =>"Exit", -command=>sub{exit 0}); #end pulldown commands for file menu #pulldown commands for the custom menu $menu_pulldown2->command(-label=>"Create Custom Edits", -command=>sub {$call_entry->Gui()}); $menu_pulldown2->separator(); $menu_pulldown2->command(-label=>"List Custom Edits", -command=>sub {$call_list->Gui()}); $menu_pulldown2->separator(); #$menu_pulldown2->command(-label=>"Commit Changes from List", -command=> sub{commit_changes()}); #end pulldown commands for custom menu #Buttons $button1 =$top->Button(-text =>"Command Prompt Open from Explorer", -foreground=>"red", -command =>sub{c_prompt()}); $button2 =$top->Button(-text =>"Don't Show Last User", -foreground=>"red", -command => sub{last_user()}); $button3 =$top->Button(-text =>"Personalized Logon Bitmap", -foreground=>"red", -command =>sub{bitmap()}); $button_undo_1 =$top->Button(-text =>"Undo Prompt", -foreground=>"blue", -command=>sub{undo_c_prompt()}); $button_undo_2 =$top->Button(-text =>"Undo Last User", -foreground=>"blue", -command=>sub{undo_last_user()}); $button_undo_3 =$top->Button(-text =>"Undo Bitmap", -foreground=>"blue", -command=>sub{undo_bitmap()}); #end Buttons #Label Area $label = $top->Label(-text => "Non-Critical Registry Edits", -background=>"DarkSlateGray3", -relief=>"groove", -width=>"30", -height=>"4", -font=>"{Times New Roman} 12 {normal}"); #end Label Area #text for info button $menu_popup = $menu->Button(-text=>"Help", -underline=>0, -relief=>"flat",-command => sub { $newtop = $top->Toplevel(); $newtop->title('Copyright Info'); $copyright = $newtop->Button(-text=>"Copyright Info",-command =>sub {system "notepad copyright.txt"});#this button opens a notepad file with instructions $copyright->pack(); $help = $newtop->Button(-text=>"Help", -command=> sub {system "notepad front_help.txt"}); $help->pack(); $canvas = $newtop->Canvas(); $canvas->pack(); }); #end text for info button #packs $menu->pack(-side=>'top', -fill=>'x'); $menu_pulldown1->pack(-side,'left'); $menu_pulldown2->pack(-side,'left'); $menu_popup->pack(-side,'right'); $label->pack(-side=>"top",-fill=>"x"); $frame1 =$top->Frame()->pack(-fill=>"x",-pady=>"2.5p"); #pack frames and pady 2.5 pixels $frame2 =$top->Frame()->pack(-fill=>"x",-pady=>"2.5p"); # " $frame3 =$top->Frame()->pack(-fill=>"x",-pady=>"2.5p"); # " $button1 =$frame1->Button(-text =>"Command Prompt Open from Explorer", -foreground=>"red", -command =>sub{c_prompt()})->pack(-side=>"left",-fill=>"x"); $button_undo_1 =$frame1->Button(-text =>"Undo Prompt", -foreground=>"blue", -command=>sub{undo_c_prompt()})->pack(-side=>"right",-fill=>"x"); $button2 =$frame2->Button(-text =>"Don't Show Last User", -foreground=>"red", -command => sub{last_user()})->pack(-side=>"left",-fill=>"x"); $button_undo_2 =$frame2->Button(-text =>"Undo Last User", -foreground=>"blue", -command=>sub{undo_last_user()})->pack(-side=>"right",-fill=>"x"); $button3 =$frame3->Button(-text =>"Personalized Logon Bitmap", -foreground=>"red", -command =>sub{bitmap()})->pack(-side=>"left",-fill=>"x"); $entry1 = $frame3->Entry(-textvariable => \$location, -background=>"DarkSlateGray3", -borderwidth=>4)->pack(-side=>"left"); $button_undo_3 =$frame3->Button(-text =>"Undo Bitmap", -foreground=>"blue", -command=>sub{undo_bitmap()})->pack(-side=>"right",-fill=>"x"); #end packs MainLoop; } #End Gui #********************************************************************************** # Standard edits, utilizing the Perl module Win32::Registry. # The custom edits in regentry.pm create/utilize *.reg files, # (Standard formating of *.reg files). sub c_prompt { ################################################################################### #Command Prompt from Windows Explorer Right Click ################################################################################### my $Register = "Directory\\Shell"; $HKEY_CLASSES_ROOT->Open($Register,$hkey)|| die $!; $hkey->SetValue("CommandPrompt",REG_SZ,"Command Prompt Here"); $hkey->Close(); my $Register2 = "Directory\\Shell\\CommandPrompt"; my $commandp = "cmd.exe /k cd %1"; $HKEY_CLASSES_ROOT->Open($Register2,$hkey)||die $!; $hkey->SetValue("command",REG_SZ,$commandp); $hkey->Close(); #********************************************************************************** } sub last_user { ################################################################################### #Don't Display Last User Name ################################################################################### my $Register3 = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"; undef $garbage; $HKEY_LOCAL_MACHINE->Open($Register3,$hkey)||die $!; $hkey->SetValueEx("DontDisplayLastUserName",$garbage,REG_SZ,"1"); $hkey->Close(); #********************************************************************************** } sub bitmap { ################################################################################### #Change Logon Bitmap ################################################################################### my $Register4 = ".DEFAULT\\Control Panel\\Desktop"; my $bitmap_path = "$location"; # replace '?' with path to desired .bmp. Use entry box. my $LogonBitmap = $bitmap_path; $HKEY_USERS->Open($Register4,$hkey)||die $!; $hkey->SetValueEx("Wallpaper",$garbage,REG_SZ,$LogonBitmap); #********************************************************************************** } sub undo_c_prompt { ################################################################################### #Undo Command Prompt from Explorer ################################################################################### $register6="Directory\\Shell\\CommandPrompt"; $HKEY_CLASSES_ROOT->Open($register6,$hkey)||die $!; $hkey->DeleteKey ("Command"); $hkey->Close(); $register6="Directory\\Shell"; $HKEY_CLASSES_ROOT->Open($register6,$hkey)||die $!; $hkey->DeleteKey ("CommandPrompt"); $hkey->Close(); #********************************************************************************** } sub undo_last_user { ################################################################################### #Undo Show Last User ################################################################################### $register7="Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"; $HKEY_LOCAL_MACHINE->Open($register7,$hkey)||die $!; $hkey->DeleteValue ("DontDisplayLastUserName"); $hkey->Close(); #********************************************************************************** } sub undo_bitmap { ################################################################################### #Undo Logon Bitmap ################################################################################### $register8=".DEFAULT\\Control Panel\\Desktop"; $HKEY_USERS->Open($register8,$hkey)||die $!; $hkey->DeleteValue ("Wallpaper"); $hkey->Close(); #********************************************************************************** }