Running a command (VBScript)

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 VBScript code from this site.

strServer = "\\dhcp01"  ' set this to "" to target the local computer
strCommand = "netsh dhcp server " & strServer & " set auditlog d:\dhcp\audit"

set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run(strCommand, 0, TRUE)
if intRC <> 0 then
   WScript.Echo "Error returned from running the command: " & intRC
else
   WScript.Echo "Command executed successfully"
end if

This code has been viewed 2924 times.

New from the creators of TechTasks.com: StatSheet.com