Answered netsh int tcp reset

  • Tuesday, February 28, 2012 11:58 PM
     
     

    I've made a batch file to reset tcp settings to default and when I right click it and run as administrator it runs just fine. However, when I call the batch file from my program which already has a manifest requiring admin rights, (or attempt to run the commands directly from the program using the ProcessStartInfo class), netsh returns this error: "Reset of all TCP parameters FAILED: Unable to set global on ipv4.\nThe parameter is incorrect."


    Aaron Chapman

All Replies

  • Wednesday, February 29, 2012 12:37 AM
     
     
    You may want to consider posting the code that you are using.

    It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.

  • Wednesday, February 29, 2012 12:37 AM
    Moderator
     
     

    Hello Aaron Chapman, welcome to the MSDN forums.

    If you have specific questions and coding issues, it is a big help if you post a code sample that demonstrates or reproduces the issue.  Here is a link to a thread to someone who was able to successfully call netsh from C# code. 

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9f823655-532c-4aa2-955f-d2029b723e9e/  

    If you continue to have issues, be sure to tell us which version of Visual Studio you are using, and more importantly on which OS you are trying to run netsh.

    Hope this helps. 

    Rudy   =8^D


    Mark the best replies as answers. "Fooling computers since 1971."

    http://thesharpercoder.blogspot.com/

  • Wednesday, February 29, 2012 12:45 AM
     
      Has Code

    Operating System: Windows 7 Home Premium SP1 64-bit

    Visual C# 2010 Express

            private void button1_Click(object sender, EventArgs e)
            {
                ProcessStartInfo psi = new ProcessStartInfo("netsh");
                psi.Arguments = "int tcp reset";
                psi.UseShellExecute = false;
                psi.CreateNoWindow = false;
                Process p = Process.Start(psi);
                p.PriorityBoostEnabled = true;
            }


    Aaron Chapman

  • Wednesday, February 29, 2012 4:31 AM
     
     

    Try run "int tcp dump" there to see if there's any non-recognized setting in the "set global" command there.

  • Thursday, March 01, 2012 6:28 AM
     
      Has Code

    This is what came up:

    # ----------------------------------
    # TCP Configuration
    # ----------------------------------
    pushd interface tcp
    
    reset
    
    set global rss=enabled chimney=automatic autotuninglevel=normal congestionprovid
    er=none ecncapability=disabled timestamps=disabled netdma=enabled dca=enabled
    
    
    popd
    # End of TCP configuration

    And like I said before, if I do it all manually, everything works great. It seems to only happen when "netsh.exe" is executed through a visual studio application.


    Aaron Chapman


  • Thursday, March 01, 2012 6:42 AM
     
      Has Code

    Another thing, if I run "cmd.exe" w/o admin rights, and try to run the command: "netsh int tcp reset", it gives me some weird message at the beginning. Maybe I'm reading it wrong or maybe it's just poorly formatted I don't know but this is what comes up (without admin rights):

    >netsh int tcp reset
    
    Show chimneyapplication command failed while retreiving  settings.
    The requested operation requires elevation (Run as administrator).
    
    >

    Maybe this has something to do with it? Cause I know that "Show chimneyapplications" is a command but not "Show chimneyapplication"... And why would it be running that command in the first place? I never passed that command to the netsh application...


    Aaron Chapman

  • Thursday, March 01, 2012 9:27 AM
     
      Has Code

    For my Win7 with UAC enabled, I can execute "int tcp dump"

    # ----------------------------------
    # TCP Configuration
    # ----------------------------------
    pushd interface tcp
    reset
    set global rss=enabled chimney=automatic autotuninglevel=normal congestionprovid
    er=none ecncapability=disabled timestamps=disabled netdma=disabled dca=disabled
    Dump has failed when retreiving chimneyapplication  settings.
    Dump has failed when retreiving chimneyapplication  settings.
    Dump has failed when retreiving chimneyapplication  settings.
    Dump has failed when retreiving chimneyapplication  settings.
    popd
    # End of TCP configuration

    Or if you want a more meaningful view, "int tcp show global"

    netsh interface tcp>show global
    Querying active state...
    TCP Global Parameters
    ----------------------------------------------
    Receive-Side Scaling State          : enabled
    Chimney Offload State               : automatic
    NetDMA State                        : enabled
    Direct Cache Acess (DCA)            : disabled
    Receive Window Auto-Tuning Level    : normal
    Add-On Congestion Control Provider  : none
    ECN Capability                      : disabled
    RFC 1323 Timestamps                 : disabled
    ** The above autotuninglevel setting is the result of Windows Scaling heuristics
    overriding any local/policy configuration on at least one profile.

    I don't know if your output omitted the "set global" line, but if your code can't see this line, your application probably doesn't have the right to read/write the TCP configuration (after reset, the netsh command still have to set some default state based on the default parameters. it probably can't get the global parameters to set afterwards).

  • Monday, March 05, 2012 12:58 AM
     
     
    That line shows up on mine too? And why do you think that is?

    Aaron Chapman

  • Monday, March 05, 2012 1:02 AM
     
      Has Code

    And if I comment out the 'arguments' and run the code:

            private void button1_Click(object sender, EventArgs e)
            {
                ProcessStartInfo psi = new ProcessStartInfo("netsh");
                //psi.Arguments = "int tcp reset";
                psi.UseShellExecute = false;
                psi.CreateNoWindow = false;
                Process p = Process.Start(psi);
                p.PriorityBoostEnabled = true;
            }

    it will open the netsh application, but when I manually type "int tcp reset" into the command prompt, it still fails! Which leads me to believe it has to do with the application that started "netsh.exe"... It seems that if "explorer.exe" is not the parent process, then "netsh.exe" will fail no matter what.


    Aaron Chapman


  • Monday, March 05, 2012 4:26 AM
     
     Answered
    Okay I've solved the issue using Process Monitor, it had something to do with the file system redirector redirecting my application to the "SysWOW64" directory. I had to disable that function using PInvoke... Thank you so much for all yalls help though!

    Aaron Chapman