Solved

cmd dnscmd .net c#

Posted on 2010-09-05
6
1,258 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now