Share via

Much slower performance accessing network shared files when starting App from Administrator mode

Anonymous
2023-01-16T04:13:00+00:00

Hi there,

We have met quite strange behavior when starting the same application (AutoCAD Civil 3D) from Administrator mode, it shows a much slower performance when we access network sharing paths like \automation_server\some_folder\a.file.

The main APIs we are using is _taccess(), GetFileAttributes(), CreateFile(), GetFileTime().

The problem was found accidentally when we tested performance when working with net share files, and frequent file access does impact the performance. We certainly have a lot of not-needed API calls, but then we start the application from Administrator mode, and it becomes totally unusable - sometimes it looks like a hang although, after 30 minutes, the app can react again. It looks like the net share file access is not cached at all.

The first question is: are there any differences between non-Admin and Admin mode?

And even strangely, if I write some test applications (C#) to call File.Exists() and File.GetLastWriteTime() many times, and the 'cache' seems indeed working. So it looks like it's our own code issue.

Then we found a piece of code like below:

if (::GetFileAttributes(fileName) != INVALID_FILE_ATTRIBUTES) {

    HANDLE hFile = ::CreateFIle(fileName,
                                GENERIC_READ,
                                FILE_SHARE_READ | FILE_SHARE_WRITE,
                                NULL, OPEN_EXISTING, 0, NULL);

    if (hFile != INVALID_HANDLE_VALUE) {
        FILETIME ftCreationTime, ftLastAccessTime, ftLastWriteTime;

        ::GetFileTime(hFile,  &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime);

   }
}

And GetFIleAttributes was called for getting the last write time, which was actually not needed. Then we remove it and it seems the non-Admin and Admin now have the same performance.

So the second question is: is this indeed the reason for causing the non-Admin and Admin difference?

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2023-01-16T05:34:38+00:00

    Hello Angelo,

    You're most welcome. I'm glad to help.

    Stay safe and have a great day.

    Kind regards,

    John DeV

    Independent Advisor

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-01-16T05:30:34+00:00

    Thank you John, I will get it asked there!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-01-16T04:45:44+00:00

    Hello Angelo,

    Good day! I'm John DeV a Windows user like you and I'll be happy to assist you today.

    Due to the scope of your question, It is best to ask this on Microsoft Site Q&A which is a technical community platform where most of the members were IT professionals that would greatly help you with the issue.

    Microsoft Site Q&A

    https://docs.microsoft.com/en-us/answers/products/

    Kind regards,

    John DeV

    Independent Advisor

    Was this answer helpful?

    0 comments No comments