none
Can't find telnet.exe RRS feed

  • Question

  • I have an application that should start a telnet session. The code it uses is:

    Process telnetProcess = new Process();
    string telnetexe = string.Format("{0}\\telnet.exe", Environment.GetFolderPath(Environment.SpecialFolder.System));
    if (File.Exists(telnetexe))
    {
         telnetProcess.StartInfo.FileName = telnetexe;
         telnetProcess.StartInfo.Arguments = "-a " + name;
         telnetProcess.Start();
    }
    


    the string telnetexe provides a value of "C:\\Windows\\System32\\telnet.exe" as expected and using Windows explorer i can see and run the telnet client directly.

    The problem is that File.Exists always returns false.

    I use the exact same code for starting a remote desktop session - mstsc.exe which is in the same directory.

    Why can't .NET find telnet?

    Thursday, January 19, 2012 12:53 PM

Answers

  • If you are running your application in 32 bit OS, then your code should work if telnet.exe is really present in System32 bit folder.

    On the other hand, if you are running 64 bit machine, your query may be redirected to different folder depending on whether your application is 32 bit application or 64 bit application. If it is 32 bit application, though you give System32 folder, it will be re-directed to SysWoW64 folder and telnet.exe may not be present there.


    Please mark this post as answer if it solved your problem. Happy Programming!
    • Marked as answer by Adam Dove Friday, January 20, 2012 8:32 AM
    Thursday, January 19, 2012 3:33 PM

All replies

  • If you are running your application in 32 bit OS, then your code should work if telnet.exe is really present in System32 bit folder.

    On the other hand, if you are running 64 bit machine, your query may be redirected to different folder depending on whether your application is 32 bit application or 64 bit application. If it is 32 bit application, though you give System32 folder, it will be re-directed to SysWoW64 folder and telnet.exe may not be present there.


    Please mark this post as answer if it solved your problem. Happy Programming!
    • Marked as answer by Adam Dove Friday, January 20, 2012 8:32 AM
    Thursday, January 19, 2012 3:33 PM
  • Have you enabled telnet? (Just to be sure.)
    Regards, MusicDemon
    Friday, January 20, 2012 7:54 AM