Search Unity

UAC windows builds

Discussion in 'Windows' started by Fuzzypup, Jul 14, 2021.

  1. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    The games I make allow for user mods to be used. It also uses some outside data the user can change. But I run into problems when I try access data under MyDocuments\"name of game"\Data

    The game is installed under C:\Program Files (x86)\"name of game"

    I have to run the game as administrator always.

    It accesses the MyDocument folder to grab user created data or import data to a new scenario. But windows prevents it without admin access.

    I can't seem to find anything anywhere on this subject except about UnityHUB itself.

    The game needs to run using UAC and not set as admin. Only on PCs where the user is an admin does it run properly. Otherwise I have to tell them to set the game as admin.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    How do you access these files? Can you show your code? The standard way of allowing to pick file where your app doesn't have access to is using a native OS file picker.
     
  3. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    It's just a simple System.IO.File.ReadAllLines or binary reader
    It doesn't even do this System.IO.Directory.GetFiles....
    The read from C:\Users\"my user name"\Documents\My Games\"my game"

    If I run it as admin or run it as an admin user it works just fine.
    If I run it from a non-admin user account it doesn't work without setting the game to "run as admin".
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you show the code that computes the path? Are you by any chance trying to read from the wrong user documents folder? Non-admin accounts can only see their own documents.
     
  5. Fuzzypup

    Fuzzypup

    Joined:
    Aug 13, 2013
    Posts:
    190
    I was just posting to say I discovered what it was and that was it. It was reading from a different user account where the data was under the installer's user ID.

    That I can solve on my own.

    Now looking back I think duh it's so obvious.