Solved

cmd dnscmd .net c#

Posted on 2010-09-05
6
1,264 Views
Last Modified: 2013-12-17
Hi

Been trying to tidy up DNS server in windows by delting unneeded zone files

Have found that using command window and issuing the command
> dnscmd /zonedelete domainnametodelete.tld /f

will delete zone very quickly but I want to ru this inside a .net c# form as want to access the database with the names of the zone to delete

Any ideas on how to run this code inside a c# .net application please
Rgds
stephen
0
Comment
Question by:stephenwilde
  • 4
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33606630

System.Diagnostics.Process.Start("dnscmd", "/zonedelete domainnametodelete.tld /f");

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33606632
Or possibly:
System.Diagnostics.Process.Start("cmd", "dnscmd /zonedelete domainnametodelete.tld /f");

Open in new window

0
 

Author Comment

by:stephenwilde
ID: 33607829
Thanks

Is there a way to capture the response text from the cmd?

Rgds
stephen
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 33608756
Yes. You have to redirect output before you can read it, though. Here is an example. Be sure to leave "UseShellExecute = false", otherwise you will get an error when you try to redirect.
using System.Diagnostics;

...

ProcessStartInfo info = new ProcessStartInfo("cmd", "dnscmd /zonedelete domainnametodelete.tld /f");

info.UseShellExecute = false;
info.RedirectStandardOutput = true;

Process p = Process.Start(info);

p.WaitForExit();

string output = p.StandardOutput.ReadToEnd();

Open in new window

0
 

Author Closing Comment

by:stephenwilde
ID: 33609486
Thanks very much
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 33619978
NP. Glad to help  :)
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a multi-homed DNS setup in windows, you can have issues with connectivity to the server that hosts the DNS services (or even member servers of your domain if this same DNS server is a DC). This is because windows registers all of its IPs…
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question