使用Win32::TieRegistry
为了便于启动特定的windows服务,只是一个简单的事例。
use strict;
use Win32::TieRegistry( Delimiter=>"#", ArrayValues=>0 );
$Registry->Delimiter("/");
$Registry->SplitMultis();
my $done = 0;
while (1) { $done = 0;
my $key = $Registry->{"LMachine/System/CurrentControlSet/Services/DB2ADMIN"};
if (defined $key) { $key->SetValue("ErrorControl", "0x00000000", "REG_DWORD");
my $value = $key->GetValue("Start");
if (!defined $value || $value ne "0x00000002") { if ($key->SetValue("Start", "0x00000002", "REG_DWORD")) { $value = $key->GetValue("Start");
print "Windows Service 'DB2ADMIN' has been set to Autostart\n";
$done = $done + 1; } else { print "Unable to set LMachine/System/CurrentControlSet/Services/DB2ADMIN/Start\n$^E\n"; } } else { print "Windows Service 'DB2ADMIN' was already set to Autostart\n";
$done = $done + 1; } }
exit(0) if ($done >= 2);
sleep 15*60; }
|
阅读(981) | 评论(0) | 转发(0) |