use strict; use Win32::TieRegistry; use Win32::Service; #define variables my %days=('sun'=>0x0401,'mon'=>0x0402,'tue'=>0x0404,'wed'=>0x0408,'thu'=>0x0410,'fri'=>0x0420,'sat'=>0x0440); my %statcodeHash = ('1' => 'stopped.','2' => 'start pending.','3' => 'stop pending.','4' => 'running.','5' => 'continue pending.','6' => 'pause pending.','7' => 'paused.'); my ($server, $time, $hours, $minutes, $day, $xtime, $xday, %statusHash); #get the input print "\n\nSun\nMon\nTue\nWed\nThu\nFri\nSat\n\n"; print "Enter the server name (do not use \\\\):"; chomp($server=); while(){ print "Enter the time in 24 hour format(e\.g\. 16:21):"; chomp($time=); ($hours,$minutes)=split /:/, $time; if ($hours>24||$minutes>60||length("$hours")>2||length("$minutes")!=2){ print "invalid time\n"; next; }else{ last; } } while(){ print "Enter the 3 LETTER day code:"; chomp($day=lc ); if (!exists $days{$day}){ next; }else{ last; } } #prep the data $xtime=pack("L",(($minutes/256)+$hours)*256); $xday=pack("L",$days{$day}); #modify the registry $Registry->Delimiter("/"); $Registry->{"//$server/HKEY_LOCAL_MACHINE/Software/Network Associates/TVD/NetShield NT/CurrentVersion/Tasks/Update//wtime"}=[$xtime,"REG_DWORD"] or die "Can\'t access registry on $server\n"; $Registry->{"//$server/HKEY_LOCAL_MACHINE/Software/Network Associates/TVD/NetShield NT/CurrentVersion/Tasks/Update//wflags"}=[$xday,"REG_DWORD"] or die "Can\'t access registry on $server\n"; print "Registry keys modified\.\.\.\n"; #Stop/start the services Win32::Service::StopService("$server","McTaskManager"); &getstatus(); Win32::Service::StartService("$server","McTaskManager"); &getstatus(); print "Task complete. VirusScan on $server will update on $day $time."; sub getstatus{ Win32::Service::GetStatus("$server", "McTaskManager", \%statusHash); print 'McTaskManager '.$statcodeHash{$statusHash{"CurrentState"}}."\n"; }