############################################################################## #John McKee #regentry.pm # # # This is an extension program to genericreg.pl # 1. This is a GUI which allows the user to # create a set of custom registry edits # and save those edits to a file. # # Unresolved Issues # 1. In-Depth Help File # 2. Clear all entry boxes when a new radiobutton is pushed # ############################################################################## package regentry; use Tk; use Tk::Menubutton; use Tk::Canvas; use Tk::Entry; use Tk::Radiobutton; #Constructor sub new { bless{}; } #end constructor sub Gui { #Gui, Title, and Warning Label $top = MainWindow->new(); $top->title('Custom Registry Edits'); $label = $top->Label(-text => "REALLY!\n Don't do this unless you know\n what you're doing or willing\n to suffer the chaos that\n can ensue from monkeying\n with the all mighty registry hive!", -background=>"DarkSlateGray3", -relief=>"groove", -width=>"32", -height=>"6", -font=>"{Times New Roman} 12 {normal}")->pack(); #end Gui, Title, and Warning Label #RadioButtons for desired registry hive $top->Radiobutton (-text => "HKEY_CLASSES_ROOT", -variable=>\$regkey, -value=>"HKEY_CLASSES_ROOT", -activeforeground=>"blue")->pack(); $top->Radiobutton (-text => "HKEY_CURRENT_USER", -variable=>\$regkey, -value=>"HKEY_CURRENT_USER", -activeforeground=>"blue")->pack(); $top->Radiobutton (-text => "HKEY_LOCAL_MACHINE", -variable=>\$regkey, -value=>"HKEY_LOCAL_MACHINE", -activeforeground=>"blue")->pack(); $top->Radiobutton (-text => "HKEY_USERS", -variable=>\$regkey, -value=>"HKEY_USERS", -activeforeground=>"blue")->pack(); $top->Radiobutton (-text => "HKEY_CURRENT_CONFIG", -variable=>\$regkey, -value=>"HKEY_CURRENT_CONFIG", -activeforeground=>"blue")->pack(); $top->Radiobutton (-text => "HKEY_DYN_DATA", -variable=>\$regkey, -value=>"HKEY_DYN_DATA", -activeforeground=>"blue")->pack(); #end RadioButtons for desired registry hive #Labels for Custom Edits $regedit = "Enter the registry hive you wish to edit:"; $create_key = "Enter name of key to create/edit:"; $create_value = "Enter name of value to create/edit:"; $memo ="Name for this change:"; #end Labels #Separate Frames for better look $frame4 =$top->Frame()->pack(); $frame1 =$top->Frame()->pack(); $frame2 =$top->Frame()->pack(); $frame3 =$top->Frame()->pack(); #end Frames #Label and Entry Boxes with packing $label1 = $frame1->Label(-textvariable => \$regedit)->pack(-side=>"left"); $entry1 = $frame1->Entry(-textvariable => \$text)->pack(-side=>"left"); $label2 = $frame2->Label(-textvariable => \$create_key)->pack(-side=>"left"); $entry2 = $frame2->Entry(-textvariable => \$text2)->pack(-side=>"left"); $label3 = $frame3->Label(-textvariable => \$create_value)->pack(-side=>"left"); $entry3 = $frame3->Entry(-textvariable => \$text3)->pack(-side=>"left"); $label4 = $frame4->Label(-textvariable => \$memo)->pack(-side=>"left"); $entry4 = $frame4->Entry(-textvariable => \$name)->pack(-side=>"left"); #end Label and Entry Boxes #Buttons Save, Close, Help #Note: Save button also clears entry boxes $top->Button(-text=>"Save RegEdits to a File", -foreground=>"blue", -command=>sub{save(),$entry1->delete( 0, 'end' ),$entry2->delete( 0, 'end' ),$entry3->delete( 0, 'end' ),$entry4->delete( 0, 'end' )})->pack(); #sub to save selections $top->Button(-text=>"Close", -foreground=>"blue", -command=> sub {$top->destroy()})->pack(); $top->Button(-text=>"Help (Don't be afraid to use this)", -foreground=>"white", -background=>"red", -command=>sub {system "notepad regentry_hlp.txt"})->pack(); #end Buttons MainLoop; } #End Gui #***************************************************************************** ########################################################################## #Filehandler for the custom edits #Creates *.reg files based on the name & values given in the entry gui ########################################################################## sub save () { open (FD, ">$name.reg")||die "Unable to open storage file"; print FD "REGEDIT4\n\n[$regkey\\$text]\n\"$text2\"=\"$text3\"\n"; close (FD); } #************************************************************************* return 1;