Solved

cmd dnscmd .net c#

Posted on 2010-09-05
6
1,250 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 74

Expert Comment

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

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

Open in new window

0
 
LVL 74

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 74

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 74

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
I wrote this article to explain some important DNS concepts that should be known to avoid some typical configuration errors I often see in forums. I assume that what is described here is the typical behavior of Microsoft DNS client. I don't know …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

10 Experts available now in Live!

Get 1:1 Help Now