1

I have an application that uses an config.xml file that is stored in C:\ProgramData\MyApp

The config file is created and edited using MyConfigApp.exe and then read by the actual application MyApp.exe.

During the installation I was logged in as Administrator and everything worked perfect!. Then we logged in as a normal user and it worked perfect here as well.

Then we needed to change a configuration. This is something a user should be able to do, so we started MyConfigApp.exe and changed the configuration.

But the change was never read into MyApp.exe.

I opened c:\ProgramData\MyApp\config.xml and the old values where in it.

Now we discovered that the user didn't have any write rights in ProgramData directory. So Windows created a new file in VirtualStore, which is not used from MyApp.exe

We added Write rights in ProgramData (and subdirectories) and removed the config.xml file from VirtualStore.

BUT every time the user runs MyConfigApp.exe it will create a file in VirtualStore!

How do I make MyConfigApp.exe read and write the file in ProgramData?

1
  • A folder within VirtualStore is percisely where this file should go. Your conclusion the user not having write access to ProgramData was clearly wrong if the program still does not load the configuration. This seems more like a SO question since, the only way I could answer it, is to see your code.
    – Ramhound
    Commented May 3, 2016 at 20:54

1 Answer 1

1

I solved this with my legacy application by creating a .manifest file, which is placed alongside the exe. No real problems, just a text file called MyConfigApp.exe.manifest which contains something like the XML code below.

According to Microsoft, (see https://msdn.microsoft.com/en-us/library/bb756929.aspx) an EXE with a side-by-side manifest file like the one below will not participate in file system virtualization because a specific execution level is requested, and therefore won't add things to a user's VirtualStore.

However, be aware that the system will use VirtualStore if there are files already there. Here's the manifest code:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="**your version number, make sure the numbers match the EXE**"
    processorArchitecture="X86"
    name="MyConfigApp"
    type="win32"
    />
  <description>SOLIDCast</description>
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
       <application>
           <!-- Windows 8.1 -->
            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
           <!-- Windows 8 -->
            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
           <!-- Windows 7 -->
            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
           <!-- Windows Vista -->
            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
       </application>
    </compatibility>
<!-- Identify the application security requirements: Vista and above -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
        <requestedPrivileges>
          <requestedExecutionLevel
            level="asInvoker"
            uiAccess="false"
            />
        </requestedPrivileges>
      </security>
  </trustInfo>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .