Running a command (Perl)
This code can be found in
Chapter 11 of Windows Server 2003 Security Cookbook
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.
use Win32::OLE;
$strServer = '\\\\dhcp01';
# set this to "" to target the local computer
$strCommand = 'netsh dhcp server ' . $strServer . ' set auditlog d:\\dhcp\\audit';
$objWshShell = Win32::OLE->new('WScript.Shell');
$intRC = $objWshShell->Run($strCommand, 0, 1);
if ($intRC != 0) {
print 'Error returned from running the command: ' . $intRC, "\n";
}
else {
print "Command executed successfully\n";
}
|
This code has been viewed 947 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|