Restart the DNS Server service (Perl)
This code can be found in
Chapter 14 of DNS on Windows Server 2003
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# Restart the DNS Server service
# ---------------------------------------------------------------
# From the book "DNS on Windows Server 2003"
# By Cricket Liu, Matt Larson & Robbie Allen
# Publisher: O'Reilly and Associates
# ISBN: 0-596-00562-8
# Book web site: http://rallenhome.com/books/dnsonw2k3/toc.html
# ---------------------------------------------------------------
use Win32::OLE;
$strServer = 'terminator.movie.edu';
$objDNS = Win32::OLE->GetObject('winMgmts:\\\\' . $strServer . '\\root\\MicrosoftDNS');
$objDNSServer = $objDNS->Get('MicrosoftDNS_Server.Name="."');
$objDNSServer->StopService();
if ((0 + Win32::OLE::LastError())) {
print 'StopService failed: ' . ('' . Win32::OLE::LastError()), "\n";
exit 0;
}
$objDNSServer->StartService();
if ((0 + Win32::OLE::LastError())) {
print 'StartService failed: ' . ('' . Win32::OLE::LastError()), "\n";
exit 0;
}
print "Restart successful\n";
|
This code has been viewed 1186 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|