teksupsm Posted April 18, 2014 Posted April 18, 2014 (edited) I have a simple script that I want to run to blackhole some DNS sites (I know there are other scripts our there that do this in powershell and VB). I am having some issues with getting it to run properly because it does not seem to be submitting my variables in the run statement. I have highlighted the part that does not seem to work (tried both run and run(@ComSpec... Global $domain = "somedomain.com" Global $ipaddr = "127.0.0.1" Global $command = "dnscmd.exe " Global $zoneparameter = string(" /zoneadd " & $domain & " /Primary /file 000-sinkholed-domain.local.dns") Global $ipparameter = string(" /RecordAdd " & $domain & " @ A " & $ipaddr) Global $dns1 = "dnsserver1.local" $domcreate1 = $command & $dns1 & $zoneparameter $ipcreate1 = $command & $dns1 & $ipparameter ;why don't these work? Run($domcreate1) Run($ipcreate1) ;or these? Run(@ComSpec & " /c " & 'dnscmd.exe ' & $zoneparameter, "", @SW_SHOW) Run(@ComSpec & " /c " & 'dnscmd.exe ' & $ipparameter, "", @SW_SHOW) Edited April 18, 2014 by teksupsm
hunte922 Posted April 18, 2014 Posted April 18, 2014 By the looks of it, you're missing a quotation at the end of Global $dns1 = "dnsserver1.local
teksupsm Posted April 18, 2014 Author Posted April 18, 2014 You are correct I was missing a " , however, the run command still does not work. If I debug to message box it shows the following. For the run commands.... Run($domcreate1) Run($ipcreate1) For the run(@ComSpec commands.... Run(@ComSpec & " /c " & 'dnscmd.exe ' & $zoneparameter, "", @SW_SHOW) Run(@ComSpec & " /c " & 'dnscmd.exe ' & $ipparameter, "", @SW_SHOW)
Solution teksupsm Posted April 18, 2014 Author Solution Posted April 18, 2014 Found the answer.... It was the File System Redirect (2008 x64) redirecting C:\Windows\System32\ to C:WindowsSysWow64 I was able to specify in the script the working dir and now it works (see changes below) $domain = "somedomain.com" $ipaddr = "127.0.0.1" $command = "dnscmd.exe " $workingdir = 'c:windowssysnative' $zoneparameter = string(" /zoneadd " & $domain & " /Primary /file 000-sinkholed-domain.local.dns") $ipparameter = string(" /RecordAdd " & $domain & " @ A " & $ipaddr) $dns1 = "dnsserver1.local" $domcreate1 = string ($dns1 & $zoneparameter) $ipcreate1 = string($dns1 & $ipparameter) RunWait($workingdir&$command & $domcreate1)RunWait($workingdir&$command & $ipcreate1)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now