سؤال

I've been trying to do some research but with no luck on how to code using Perl to change Internet Explorer's default home page. I've done a bit of coding but I haven't found anything that allows me to change the default home page. Here is the code that I've gotten done so far. Anybody have any tips or advice or even any helpful websites? Thanks!

use Win32::OLE;
print "What would you like to change Internet Explorer's default home page to?\n";
print "No spaces allowed.\n";
chomp($url=<STDIN>);
while (!$url)
{
    print "Cannot be blank! Please enter again.\n";
    chomp($url=<STDIN>);
}
while ($url)
{
    if ($url =~ /\s/)
    {
        print "No spaces. Please re-enter:\n";
        chomp($url=<STDIN>);
    }
        #This is where the code to change the homepage would go.
        print "\nYour default Internet Explorer home page has been changed!";
exit;
}
هل كانت مفيدة؟

المحلول

The Internet Explorer start page setting is kept in the Windows registry. You can manipulate the registry using Win32::TieRegistry.

I don't have a Windows box to test this on, but something like this should work:

use Win32::TieRegistry ( Delimiter => "/" );
my $settings = $Registry->{"HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/"};
$settings->{"Main/Start Page"} = "http://www.example.com/";
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top