Results 1 to 7 of 7

Thread: [SOLVED] Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2020
    Posts
    4

    Question [SOLVED] Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    For some reason I can't get this line to return True: If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH") Then MessageBox.Show("It Exists")

    The directory definitely exists. Every other directory works fine. Is this a bug?
    Last edited by bobbyskillz; Feb 7th, 2020 at 10:59 AM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,408

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Unlikely that it would be a bug, as that would be an oddly specific bug.

    The first thing I would try would be this sequence:

    System.IO.Directory.Exists("C:\Windows")

    then

    System.IO.Directory.Exists("C:\Windows\System32")

    If those return True, then I would guess that OpenSSH is not JUST OpenSSH, but might include a hidden character. If those return False, then there's probably a permissions issue. I don't know whether UAC, or anything else, impacts Directory.Exists in any way, but you'd find out easily enough.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2020
    Posts
    4

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Quote Originally Posted by Shaggy Hiker View Post
    Unlikely that it would be a bug, as that would be an oddly specific bug.

    The first thing I would try would be this sequence:

    System.IO.Directory.Exists("C:\Windows")

    then

    System.IO.Directory.Exists("C:\Windows\System32")

    If those return True, then I would guess that OpenSSH is not JUST OpenSSH, but might include a hidden character. If those return False, then there's probably a permissions issue. I don't know whether UAC, or anything else, impacts Directory.Exists in any way, but you'd find out easily enough.
    I should have mentioned I tried the parent directories and they worked without any issue, both returning true. I also ran as System (root) and still couldn't get OpenSSH to return true. icacls, cacls, and other utilities have no trouble returning information on the directory.

    The problem is across multiple Windows 10 PCs that now have OpenSSH installed as part of the system from Microsoft.

    Code:
    C:\Windows\System32>icacls OpenSSH
    OpenSSH NT SERVICE\TrustedInstaller:(F)
            NT SERVICE\TrustedInstaller:(CI)(IO)(F)
            NT AUTHORITY\SYSTEM:(M)
            NT AUTHORITY\SYSTEM:(OI)(CI)(IO)(F)
            BUILTIN\Administrators:(M)
            BUILTIN\Administrators:(OI)(CI)(IO)(F)
            BUILTIN\Users:(RX)
            BUILTIN\Users:(OI)(CI)(IO)(GR,GE)
            CREATOR OWNER:(OI)(CI)(IO)(F)
            APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(RX)
            APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(OI)(CI)(IO)(GR,GE)
            APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(RX)
            APPLICATION PACKAGE AUTHORITY\ALL RESTRICTED APPLICATION PACKAGES:(OI)(CI)(IO)(GR,GE)
    
    Successfully processed 1 files; Failed processing 0 files
    
    C:\Windows\System32>attrib OpenSSH
                         C:\Windows\System32\OpenSSH

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Pointless Forest 38.517,-92.023
    Posts
    9,313

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Quote Originally Posted by bobbyskillz View Post
    For some reason I can't get this line to return True: If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH") Then MessageBox.Show("It Exists")

    The directory definitely exists. Every other directory works fine. Is this a bug?
    I tested on my PC with the same results.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2020
    Posts
    4

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Quote Originally Posted by dbasnett View Post
    I tested on my PC with the same results.
    Thanks! This is definitely puzzling. Time to look for a Microsoft bug reporting mechanism.

  6. #6
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,304

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Quote Originally Posted by bobbyskillz View Post
    For some reason I can't get this line to return True: If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH") Then MessageBox.Show("It Exists")

    The directory definitely exists. Every other directory works fine. Is this a bug?
    Assuming you have a 64bit OS, then to access most items in the C:\Windows\System32 folder you need to compile to 64bit.
    32 bit apps will be redirected to look in C:\Windows\SysWOW64 and I don't think that folder contains an OpenSSH folder.

    There's lots of info about this on the web. For example, see https://docs.microsoft.com/en-us/win...ectedfrom=MSDN

  7. #7

    Thread Starter
    New Member
    Join Date
    Feb 2020
    Posts
    4

    Re: Weird Bug - If System.IO.Directory.Exists("C:\Windows\System32\OpenSSH")

    Quote Originally Posted by Inferrd View Post
    Assuming you have a 64bit OS, then to access most items in the C:\Windows\System32 folder you need to compile to 64bit.
    32 bit apps will be redirected to look in C:\Windows\SysWOW64 and I don't think that folder contains an OpenSSH folder.

    There's lots of info about this on the web. For example, see https://docs.microsoft.com/en-us/win...ectedfrom=MSDN
    Well. That solved the problem. Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width