Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:11:24+00:00 2026-06-13T08:11:24+00:00

I wan to add some DNS records in c# program via a bat file

  • 0

I wan to add some DNS records in c# program via a bat file so I have written these lines in bat file:

    set servername=%1
set siteaddress=%2


"C:\Windows\System32\dnscmd.exe" %servername% /zoneadd %siteaddress% /primary /file  %siteaddress%.dns

and I have written these lines in C#:

Process p = new Process();
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.WorkingDirectory = Application.StartupPath;
                    p.StartInfo.FileName = General.DnsBatPath;
                    p.StartInfo.Arguments = string.Format("{0} {1}", General.DnsServerName, txtSiteAddress.Text);
                    p.Start();
                    p.WaitForExit();

I get this error “dnscmd.exe is not recognized as internal or external command…” but when I run bat file manually (outside of C#) all things are OK.

I changed my C# code to check what happened

Process.Start(@"C:\Windows\System32\dnscmd.exe");

I still get “not recognized …” error.but I can see dnscmd.exe in “C:\Windows\System32”.
I changed my C# code again to check another thing:

Process.Start(@"C:\Windows\System32\cmd.exe");

and after that CMD windows will be opened???
any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:11:25+00:00Added an answer on June 13, 2026 at 8:11 am

    In answer to your second question, you can always check the environmental variable PROCESSOR_ARCHITECTURE to see if it contains the number 64.

    set servername=%1
    set siteaddress=%2
    
    if "%PROCESSOR_ARCHITECTURE%" equ "%PROCESSOR_ARCHITECTURE:64=%" (
      REM 32bit
      "C:\Windows\System32\dnscmd.exe" %servername% /zoneadd %siteaddress% /primary /file  %siteaddress%.dns
    ) else (
      REM 64bit
      "%windir%\Sysnative\dnscmd.exe" %servername% /zoneadd %siteaddress% /primary /file  %siteaddress%.dns
    )
    

    Possibly a more reliable method is to get it from the registry:

    set servername=%1
    set siteaddress=%2
    
    for /f "tokens=3" %%x in ('reg Query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier') do (
      set arch=%%x
    )
    if %!arch:~-2!%==64 (
      set dnsPath=%windir%\Sysnative
    ) else (
      SET dnsPath=C:\Windows\System32
    )
    "%dnsPath%\dnscmd.exe" %servername% /zoneadd %siteaddress% /primary /file  %siteaddress%.dns
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wan't to add some space between the navigationbar and the content of the
I have a very simple custom dialog and I wan't to add a positive
Lets say I wan't to add 1 to an integer. This will only be
i wan to retrieve data from query involving many tables. i have a query
I wan to monitor changes in android system file /sys/class/net/eth0/operstate for monitoring ethernet state.
i have uitextfield i wan that it should start entering text from top instead
I have some kind of an ideological question, so: Suppose I have some templated
I am creating a magazine app, in which iI wan't to add zoom functionality.
what i'm basicaly wan to do, is add somme items in a toolstripdropdownbutton. What
I'm having some paging issues when I wan't to display the next page with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.