How to re-permission the NUL device

Peter Bishop 231 Reputation points
2025-11-20T11:40:22.6733333+00:00

I have an application running on Windows Server 2022 which needs to access the NUL device; however I am getting a permissions issue. I've seen a fix relating to using "icacls" to grant permissions to the NUL device but I cannot work out the syntax to achieve this.

Can anyone advise? Thanks.

Windows for business | Windows Server | Devices and deployment | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. MotoX80 37,156 Reputation points
    2025-11-20T14:21:27.2033333+00:00

    Interesting.

    Open a command prompt and copy/paste/run these statements. What do you get?

    sc query null
    sc qc null
    sc sdshow null
    echo xxxx > nul
    echo xxxx > c:\nul
    

    Here's what I get on Win11.

    C:\>sc query null
    SERVICE_NAME: null
            TYPE               : 1  KERNEL_DRIVER
            STATE              : 4  RUNNING
                                    (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
            WIN32_EXIT_CODE    : 0  (0x0)
            SERVICE_EXIT_CODE  : 0  (0x0)
            CHECKPOINT         : 0x0
            WAIT_HINT          : 0x0
    C:\>sc qc null
    [SC] QueryServiceConfig SUCCESS
    SERVICE_NAME: null
            TYPE               : 1  KERNEL_DRIVER
            START_TYPE         : 1   SYSTEM_START
            ERROR_CONTROL      : 1   NORMAL
            BINARY_PATH_NAME   :
            LOAD_ORDER_GROUP   : Base
            TAG                : 1
            DISPLAY_NAME       : Null
            DEPENDENCIES       :
            SERVICE_START_NAME :
    C:\>sc sdshow null
    D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)
    C:\>echo xxxx > nul
    C:\>echo xxxx > c:\nul
    C:\>
    

    If you have another WS2022 machine, run those 5 commands on it and test to see if it has a problem with nul.

    Reference:

    https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows

    https://ss64.com/nt/nul.html


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-11-20T11:40:37.4133333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To set permissions for the NUL device on Windows Server, you can use the icacls command. However, it's important to note that the NUL device is a special file that represents a null device in Windows, and modifying its permissions is not a common practice and can lead to unexpected behavior.

    If you still want to proceed, the syntax for granting permissions using icacls would typically look like this:

    icacls NUL /grant <user-upn>:(f)
    

    Replace <user-upn> with the user account that needs access. The (f) indicates full control. However, since the NUL device is a system resource, you may encounter limitations or restrictions when attempting to change its permissions.

    If you're facing a permissions issue, consider checking if the application needs to run with elevated privileges or if there are other security settings that might be affecting access to the NUL device.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.