Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Windows 7 UAC prevents my app to write log data

Windows 7 UAC prevents my app to write log data

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sdancer75
    wrote on last edited by
    #1

    Windows 7 UAC prevents my application to write log data in the installation folder. The original text log file exists from the very beggining, but its empty. When I start my app with the -L parameter to start logging, it does not write anything due the UAC control. If I rum my app with Admin Priviledges then it works. As you can understand I can not suggest my client to run the app with right click and "run as an Administrator". Is there any solution for that ? Best Regards,

    sdancer75

    Richard DeemingR 1 Reply Last reply
    0
    • S sdancer75

      Windows 7 UAC prevents my application to write log data in the installation folder. The original text log file exists from the very beggining, but its empty. When I start my app with the -L parameter to start logging, it does not write anything due the UAC control. If I rum my app with Admin Priviledges then it works. As you can understand I can not suggest my client to run the app with right click and "run as an Administrator". Is there any solution for that ? Best Regards,

      sdancer75

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Yes - don't try to write files in the installation folder. Your application will not have permission to do so. Instead, create a folder for your application under one of the AppData locations - CSIDL_APPDATA, CSIDL_LOCAL_APPDATA or CSIDL_COMMON_APPDATA - and write the log files to that folder. CSIDL (Windows)[^] SHGetFolderPath function (Windows)[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      S 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Yes - don't try to write files in the installation folder. Your application will not have permission to do so. Instead, create a folder for your application under one of the AppData locations - CSIDL_APPDATA, CSIDL_LOCAL_APPDATA or CSIDL_COMMON_APPDATA - and write the log files to that folder. CSIDL (Windows)[^] SHGetFolderPath function (Windows)[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        S Offline
        S Offline
        sdancer75
        wrote on last edited by
        #3

        Thank you Is that backward compatible with windows xp/vista ? I think that win Xp does not support AppData. Is that correct ? What to do in this case ? Check the os and take a path decision specifically for it ?

        sdancer75

        Richard DeemingR 1 Reply Last reply
        0
        • S sdancer75

          Thank you Is that backward compatible with windows xp/vista ? I think that win Xp does not support AppData. Is that correct ? What to do in this case ? Check the os and take a path decision specifically for it ?

          sdancer75

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          It should be supported in XP - the folder was called "Application Data" / "Local Data" back then. They changed it to "AppData\Roaming" and "AppData\Local" in Vista to reduce the chances of code breaking the 260-character path limit. Similarly, the "Documents and Settings" folder was renamed to "Users".


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          S 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            It should be supported in XP - the folder was called "Application Data" / "Local Data" back then. They changed it to "AppData\Roaming" and "AppData\Local" in Vista to reduce the chances of code breaking the 260-character path limit. Similarly, the "Documents and Settings" folder was renamed to "Users".


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            S Offline
            S Offline
            sdancer75
            wrote on last edited by
            #5

            Thank you for your help :-) Best Regards,

            sdancer75

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups