How to stop an app from writing to one of it's files


  1. Posts : 107
    Windows7 64
       #1

    How to stop an app from writing to one of it's files


    Hi. :)

    I have an .xml that is associated with an app. Everytime I shut down the app. that .xml file is written to, which I am trying to avoid, because it is changing some values I want to keep. I have made the file "read only", but that doesn't help; the app automatically switches off the "read only" status.

    Any way of doing this?

    Thanks in advance.
      My Computer


  2. Posts : 1,800
    Windows 7 Pro x64 SP1
       #2

    jasong1968 said:
    Hi. :)

    I have an .xml that is associated with an app. Everytime I shut down the app. that .xml file is written to, which I am trying to avoid, because it is changing some values I want to keep. I have made the file "read only", but that doesn't help; the app automatically switches off the "read only" status.

    Any way of doing this?

    Thanks in advance.
    Jasong, something tells me that if the program internally has to write something to a file, then unless you can get into the program options or the source code. your going to be out of luck. Unless there is some kind of configuration file that can be setup or the program can be executed with some command line parms.

    The App is probably keeping track of usage or execution times.

    What app is doing this?

    Rich
      My Computer


  3. Posts : 107
    Windows7 64
    Thread Starter
       #3

    Hi, and thank you for taking the time to reply.

    "then unless you can get into the program options or the source code. "

    There are no prog options to deal with this, and as this is a commercial app still in dev, the source code is out of the question. Not that I would know what to do with it anyway.

    The app is Cubase, a music sequencing program. defaults.xml, which resides in the app data folder, keeps track of app-specific configuarations and settings. Positioning (x-y coordinates) of plug-ins, audio track height, color scheme, etc. The problem is, everytime the app is shut down, it changes the value of one of the strings, from a 0 to a 1. I can manually change the 1 to a 0 and save the xml, but upon every launch and shutdown, the app will automatically change that 0 back to a 1. Why do I need that string's value to be a 0? Because of a little bug, that prohibits a certain function from performing when the app sees that string's value as a 1. That function does work however, when the app sees that string's value as a 0. If you are thinking of telling me to be careful - that what I am doing can affect other functions in the app - no need. That string calls to a specific .dll to perform this function, and that .dll is not needed for any other function.

    So, what I did was, set the .xml file to "read-only", and try to change the permissions so that the app can read the .xml file upon launch (necessary) but disallow the app from writing to that file. My attempts so far have been unsuccessful. I went into the Advanced security options, where I see:

    SYSTEM
    Admin (My Comp Name)
    My Comp Name (My Comp Name)

    All are currently set to full control.

    I found that changing the permissions for SYSTEM does nothing, so I clicked on
    My Comp Name (My Comp Name) > Change Permissions > My Comp Name (My Comp Name) > Edit, and now I have a list of Allow and Deny checkboxes.

    If I check any or all of the Deny checkboxes, the equivalent Allow checkboxes stay checked, but my understanding is that the Deny permission supercedes the Allow permission - that correct?

    So, I check all the Deny the boxes, except the ones that say "Read Attrib" and "Read Permissions". The idea here, is to allow the app to have permission to read the file, but not allow it change or write to the file. When I do that, I now see a 4th entry in the Permissions dial box which was not previously there. The three that have been there all the time say Inherited from: C:\Users\My Comp Name. The fourth that was just created says Inherited from: <not inherited>. But when I do this, the app doesn't read that file upon launch - I know this because of the settings that have reverted to the defaults. If I undo those permission changes, going back to the way it was previously, then the app does read the file upon launch, and the settings are as I have left them.

    So, I am still wondering if there is any way to do this. Either through permissions, or some other way. Thanks again for any insight.
      My Computer


  4. Posts : 1,800
    Windows 7 Pro x64 SP1
       #4

    jasong1968 said:
    Hi, and thank you for taking the time to reply.

    "then unless you can get into the program options or the source code. "

    ......
    So, I am still wondering if there is any way to do this. Either through permissions, or some other way. Thanks again for any insight.
    Something tells me that if you manage to get the program to not write the the file, it will then as you found out, start with the default values. I personally don't think that there is any solution to your problem. Sorry to be the bearer of bad tidings but that's life with computers.

    Rich
      My Computer


  5. Posts : 107
    Windows7 64
    Thread Starter
       #5

    Thanks again for the time.

    There has to be something I am doing wrong with the permissions - so I can get the app to read the xml, but not write to it, no?
      My Computer


  6. Posts : 1,781
    Windows 7 Professional SP1 32-bit
       #6

    You could try a workaround: first, make a copy of the .xml file (with your preferred settings in it).

    Then, create a small batch file which first runs Cubase, waiting silently in the background until you close and exit Cubase, and then automatically copies the backup .xml file back to the original .xml, overwriting it.

    It's not quite as elegant, granted, but it should be a simple solution to your issue.
      My Computer


  7. Posts : 107
    Windows7 64
    Thread Starter
       #7

    Corazon said:
    Then, create a small batch file which first runs Cubase, waiting silently in the background until you close and exit Cubase, and then automatically copies the backup .xml file back to the original .xml, overwriting it.
    HUH?!??! lol

    Thanks for the advice, but I didn't quite follow that.

    In any event - I got it. I knew it would be a permission thing - problem was, I was missing one of the permissions originally. Got it now - and it works exactly as I was expecting it to.

    Thanks again!
      My Computer


  8. Posts : 1,781
    Windows 7 Professional SP1 32-bit
       #8

    Sorry for the confusion LOL. I thought it would be an easier solution than trying to set the file permissions, but I'm glad you got it to work that way. Happy computing :)

    BTW, what I had in mind was a simple .bat file (that you could run via a desktop shortcut) like this:
    Code:
    pushd "C:\Program Files\Cubase"
    Cubase.exe
    wait 1
    copy /y settings_backup.xml settings.xml
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:13.
Find Us