Can't Delete Folder Called COM1 on Windows Server 2019

Michael Adams 306 Reputation points
2021-12-27T21:55:25.62+00:00

Hackers attacked a Windows Server 2019, and in the process put a folder called COM1 on Drive C. I have made a number of attempts to delete this folder. Unfortunately, COM1 is a reserved name. Here is what I have tried and have failed.

I took ownership of the folder back to the Administrators group, which I was able to do. However, it did not allow the folder removal process through File Explorer.

Then I tried removing the directory from a DOS prompt.

rmdir \?\<x>:\<path_to_folder>\<COM1>

Result: "Access denied".

Then i tried renaming the folder.

ren "\.\C:\<path to folder>\COM1 TEMP

Result: "Access denied".

File Explorer shows the folder is shared, but if go to Advanced Options, it does not show up as a Share. It also does not show up
as a shared folder in Computer Management.

I tried running the attrib command from a DOS prompt. It will display the attributes of the folder, (only Archive shows). Trying to set attributes results in,

Path not found - \.\com1\

I am running out of ideas. Any help would be appreciated.

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,128 questions
Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,721 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 31,571 Reputation points
    2022-01-11T00:55:34.41+00:00

    So it came back with a file or directory called FRArX with access denied.

    Try this sequence.

    icacls \\.\c:\Progra~3\COM1  /inheritance:r  /grant:R  everyone:f /t 
    attrib -R -S -H  \\.\c:\Progra~3\com1   
    attrib -R -S -H  \\.\c:\Progra~3\com1\*  /S /D 
    rd  \\.\c:\Progra~3\COM1 /s /q 
    

    If that doesn't work, try the rename. If that works, then there should not be any restrictions on the name.

    ren \\.\c:\Progra~3\COM1 XXX
    

9 additional answers

Sort by: Most helpful
  1. Michael Adams 306 Reputation points
    2021-12-29T19:07:37.137+00:00

    Here are the results of the commands.

    161175-capture1.png

    I also found some other issues with this folder, which I believe may be causing it not to be deleted. I believe the hackers corrupted some of the directory information associated with this folder. For instance, there are no creation or modified dates.

    161271-capture2.png

    I ran the Fanbar Tool, and it shows this for the directory.

    0-00-00 00:00 - 2446-65429-65535 17756:00 - 000000000 _____ C:\ProgramData\COM1

    It should look something like this Windows INF folder.

    2021-12-18 15:54 - 2018-09-14 23:17 - 000000000 ____D C:\Windows\INF

    I believe the first date is supposed to be the Modified date. COM1 has all zeros.

    I believe the second date is supposed to be the creation date. COM1 has some crazy number in there.

    I ran these Powershell commands to see if any processes were running on the folder.

    $Regex = "C:\ProgramData\COM1"

    Get-WmiObject Win32_Process | Where {$_.CommandLine -like "$Regex"} | Select -Property Name,ProcessId,CommandLine | Format-Table

    It came back with no entries, so I don't believe any malware has locked the folder.